[Commandmethod ("AA", Commandflags.usepickset)] Public voidAA () {Database db=hostapplicationservices.workingdatabase; Document Doc=Application.DocumentManager.MdiActiveDocument; Editor Ed=Application.DocumentManager.MdiActiveDocument.Editor; //promptselectionoptions opt = new Promptselectionoptions ("\ n Please select the traction line for name and Point");Promptselectionresult PSR =ed. GetSelection (); if(PSR. Status! = Promptstatus.ok)return; Selectionset SS=PSR. Value; if(SS. Count! =2) {ed. Writemessage ("Please select the draw line for name and Point");return; } stringPointname =""; stringPointtype =""; Point3D pout=NewPoint3D (); Polyline POINTPL=NewPolyline (); Point3dcollection points=Newpoint3dcollection (); using(Transaction trans =db. Transactionmanager.starttransaction ()) {foreach(ObjectId IDinchSS. Getobjectids ()) {dbtext text= trans. GetObject (ID, Openmode.forread) asdbtext; if(Text! =NULL) Pointname =text. TextString; Polyline PL= trans. GetObject (ID, Openmode.forread) asPolyline; if(PL! =NULL) {Pointpl=PL; for(inti =0; i < pl. Numberofvertices; i++) {points. ADD (pl. Getpoint3dat (i)); }}} trans.commit (); } if(Points. Count! =3) {ed. Writemessage ("Make sure that the point's traction line is correct and that there are only 3 nodes"); } if(points[0]. Y = = points[1]. Y) {pout = points[2]; } if(points[0]. Y = = points[2]. Y) {pout = points[1]; } if(points[1]. Y = = points[2]. Y) {pout = points[0]; } Else{ed. Writemessage ("Make sure that the point leader has one end level");return; } ///////Export Point typePromptkeywordoptions Pkey =NewPromptkeywordoptions ("\ n Please select the point type [Elbow (1)/valve (2)/Straight point (3)/Tee (4)/Turn neck (5)/Up/Down (6)/Other (7)]<1>"); Pkey. Keywords.add ("1"); Pkey. Keywords.add ("2"); Pkey. Keywords.add ("3"); Pkey. Keywords.add ("4"); Pkey. Keywords.add ("5"); Pkey. Keywords.add ("6"); Pkey. Keywords.add ("7"); Pkey. Keywords.default="1"; Pkey. Appendkeywordstomessage=false; Here:promptresult PR=ed. GetKeywords (Pkey); //ed. Writemessage ("Input keyword" +PR.) Stringresult); Switch(pr. Stringresult) { Case "1": Pointtype="Elbow"; //ed. Writemessage ("Hhhhhhhhhhhhhhhhhhhhhhh");Ed. Writemessage ("\ n The point type you selected is:"+Pointtype); Break; Case "2": Pointtype="Valve"; Ed. Writemessage ("\ n The point type you selected is:"+Pointtype); Break; Case "3": Pointtype="Straight Point"; Ed. Writemessage ("\ n The point type you selected is:"+Pointtype); Break; Case "4": Pointtype="Tee"; Ed. Writemessage ("\ n The point type you selected is:"+Pointtype); Break; Case "5": Pointtype="variable diameter"; Ed. Writemessage ("\ n The point type you selected is:"+Pointtype); Break; Case "6": Pointtype="Upside Down"; Ed. Writemessage ("\ n The point type you selected is:"+Pointtype); Break; Case "7": ed. Writemessage ("\ n The point type you selected is: null value"); Break; default: ed. Writemessage ("\ nthe Invalid keyword was entered, please re-enter:"); //Break ; GotoHere ; } //ed. Writemessage (pointtype); //////output of the result/////////////// stringPath ="d:\\ New output point. csv"; FileStream FS=NewFileStream (path, filemode.append); StreamWriter SW=NewStreamWriter (Fs,encoding.getencoding ("gb2312")); Sw. WriteLine (Pointname+","+ pout. X.tostring () +","+ pout. Y.tostring () +","+Pointtype); Sw. Close (); Fs. Close ();
Learning points:
1, the output of the text, transcoding
2, the user to cross, the use of key words
3, the question point, obviously did not use Pickfirst, why also has the Pickkfirst effect????
Cad.net two times development--output name and point coordinates, point type