.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select Object Command Prompt

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
mathewkol
3128 Views, 7 Replies

Select Object Command Prompt

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.

 

Matt Kolberg
SolidCAD Professional Services
http://www.solidcad.ca /
7 REPLIES 7
Message 2 of 8
Hallex
in reply to: mathewkol

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

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 8
Hallex
in reply to: mathewkol

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

 

~'J'~

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 4 of 8
mathewkol
in reply to: Hallex

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))

 Thanks again.

Matt Kolberg
SolidCAD Professional Services
http://www.solidcad.ca /
Message 5 of 8
mathewkol
in reply to: mathewkol

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.

 

Matt Kolberg
SolidCAD Professional Services
http://www.solidcad.ca /
Message 6 of 8
Hallex
in reply to: mathewkol

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

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 7 of 8
mathewkol
in reply to: Hallex

Thank you very much HALLEX, I was able to use your code to fix mine.  It all seems to work now.

Matt Kolberg
SolidCAD Professional Services
http://www.solidcad.ca /
Message 8 of 8
Hallex
in reply to: mathewkol

Glad I could help, Matt

Happy computing 🙂

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost