calling autoCAD commands in VB.NET while CommandFlags.session is enabled

calling autoCAD commands in VB.NET while CommandFlags.session is enabled

Anonymous
Not applicable
1,179 Views
2 Replies
Message 1 of 3

calling autoCAD commands in VB.NET while CommandFlags.session is enabled

Anonymous
Not applicable

Hi,

 

I am trying to call "-laydel" command from vb.net code. However I am getting error when using 'commandflags.session. How can I call an autocad command in vb.net while commandflags.session is enabled? I need to keep commandflags.session for my application. please see part of my code below:

 

<CommandMethod("cmdLaydel", CommandFlags.Modal + CommandFlags.Session)>

Public Sub deleteLayers2()

Dim layerTodel As String = Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("USERS2")

Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument

Dim ed As Editor = doc.Editor

ed.Command("-laydel", "n", layerTodel, "", "y", "")

End Sub

 

0 Likes
1,180 Views
2 Replies
Replies (2)
Message 2 of 3

Civil3DReminders_com
Mentor
Mentor

I've never had luck sending stuff to the command line. It always seems to do it in the order I don't want.

 

I'd just delete the layer in .NET: http://forums.autodesk.com/t5/net/how-to-delete-layer-using-c-net/td-p/2409218/page/2

Civil Reminders
http://blog.civil3dreminders.com/
http://www.CivilReminders.com/
Alumni
0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks for your reply Civil3DReminders.com. I am now deleting layer in .NET. However, my problem remains. I used to call commands, including those defined in lisp within a vb.net code I created for Civil 3d 2013. but now in civil 3d 2016, the same code can't work.

 

this is what used to work:

 

Dim app As AcadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication

app.ActiveDocument.SendCommand("setq3" & vbCr)

 

Where setq3 is either an autoCad civil 3d command or a lisp command. I could even call a lisp function by enclosing it in blackets.

 

I know there has been changes since CAD 2015 (like removing fibers) but I am hopping I could still find a working way to send a command in autocad civil 3d 2016 while "commandFlags.session is enabled.

 

Thanks

 

 

0 Likes