I'm creating a VB.Net routine which will run the REVCLOUD command. In my application I prompt the user to select a single polyline using:
EntRslt = acDoc.Editor.GetEntity(EntOpts)
Then later I run the REVCLOUD command using:
acDoc.SendStringToExecute("_revcloud Object Poly No ", False, False, True)
Where Poly is the polyline I selected earlier. Of course, the line above doesn't work since "Poly" is interpreted as a string. But I would like to figure out how to pass my VB.Net selected Polyline into the REVCLOUD command.
Anyone have any advice on how I might do this? The REVCLOUD command will not accept the "Previous" selection set so setting the Implied Selectoin does not work. If my Polyline was the Last object in the database I could use the "Last" option, but it isn't.
Thanks in advance.
Solved! Go to Solution.
You better use acedCmd P/Invoke function
Give this a try:
<DllImport("acad.exe", BestFitMapping:=True, CallingConvention:=CallingConvention.Cdecl, CharSet:=CharSet.Auto)> _ Private Shared Function acedCmd(ByVal vlist_in As System.IntPtr) As Integer End Function <CommandMethod("Cloud")> _ Public Shared Sub TestCloud() Dim db As Database = HostApplicationServices.WorkingDatabase Dim doc As Document = acApp.DocumentManager.MdiActiveDocument Dim ed As Editor = doc.Editor Dim tr As Transaction = db.TransactionManager.StartTransaction() Using tr Try ' Prompt for the polyline to revcloud Dim peo As New PromptEntityOptions(vbLf & "Select first polyline:") peo.SetRejectMessage(vbLf & "Select polyline only") peo.AddAllowedClass(GetType(Polyline), True) Dim per As PromptEntityResult = ed.GetEntity(peo) If per.Status <> PromptStatus.OK Then Return End If Dim fid As ObjectId = per.ObjectId Dim obj1 As DBObject = tr.GetObject(fid, OpenMode.ForWrite) acApp.SetSystemVariable("CMDECHO", 0) Dim buf As New ResultBuffer() buf.Add(New TypedValue(5005, "_REVCLOUD")) buf.Add(New TypedValue(5005, "_O")) buf.Add(New TypedValue(5006, fid)) buf.Add(New TypedValue(5005, "_N")) acedCmd(buf.UnmanagedObject) buf.Dispose() acApp.SetSystemVariable("CMDECHO", 1) tr.Commit() Catch ex As Autodesk.AutoCAD.Runtime.Exception ed.WriteMessage(ex.Message + vbLf + ex.StackTrace) End Try End Using End Sub
I discovered one more method you may want to use,
check this as well, just change the arc sizes in the command string:
<CommandMethod("Revc", CommandFlags.Modal Or CommandFlags.Session)> _ Public Shared Sub RevCloudTest() Dim doc As Document = acApp.DocumentManager.MdiActiveDocument Dim ed As Editor = doc.Editor acApp.SetSystemVariable("osmode", 512) Dim pt As Point3d = ed.GetPoint(vbLf + "Pick a point on polyline: ").Value doc.SendStringToExecute("_REVCLOUD _A 0.1 0.3 _O " + pt.X.ToString + "," + pt.Y.ToString + ",0 _N ", True, False, False) End Sub
Thank you very much for your reply. I was able to get your first suggection to line:
I assume it has something to do with the TypedValue TypeCode 5006. I assume 5005 is a string and 5006 is an ObjectID? What would the code be for a double? Is there a list of these codes somewhere? I have looked and I've not found anythng useful.
buf.Add(New TypedValue(5005, "_OFFSET")) buf.Add(New TypedValue(5006, OffsetLength)) buf.Add(New TypedValue(5006, Pline.ObjectId))
Ok, the offset length is easy, I just use the ToString option.
But of course, in the Offset command I will need to specify a point as well. 5006 does not work; I'm not sure which integer value to use here.
Here is some constants for ResultBuffer values:
' Type of resbuf element ' credit to Alexander Rivilis Const RTNONE As Short = 5000 ' No result Const RTREAL As Short = 5001 ' Real number Const RTPOshort As Short = 5002 ' 2D poshort X and Y only Const RTSHORT As Short = 5003 ' Short integer Const RTANG As Short = 5004 ' Angle Const RTSTR As Short = 5005 ' String Const RTENAME As Short = 5006 ' Entity name Const RTPICKS As Short = 5007 ' Pick set Const RTORshort As Short = 5008 ' Orientation Const RT3DPOshort As Short = 5009 ' 3D poshort - X, Y, and Z Const RTLONG As Short = 5010 ' Long integer Const RTVOID As Short = 5014 ' Blank symbol Const RTLB As Short = 5016 ' list begin Const RTLE As Short = 5017 ' list end Const RTDOTE As Short = 5018 ' dotted pair Const RTNIL As Short = 5019 ' nil Const RTDXF0 As Short = 5020 ' DXF code 0 for ads_buildlist only Const RTT As Short = 5021 ' T atom Const RTRESBUF As Short = 5023 ' resbuf Const RTMODELESS As Short = 5027 ' interrupted by modeless dialog ' ' Error return code Const RTNORM As Short = 5100 ' Request succeeded Const RTERROR As Short = -5001 ' Some other error Const RTCAN As Short = -5002 ' User cancelled request -- Ctl-C Const RTREJ As Short = -5003 ' AutoCAD rejected request -- invalid Const RTFAIL As Short = -5004 ' Link failure -- Lisp probably died Const RTKWORD As Short = -5005 ' Keyword returned from getxxx() routine Const RTINPUTTRUNCATED As Short = -5008
Thank you very much HALLEX, I was able to use your code to fix mine. It all seems to work now.