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

How to execute command during other command

2 REPLIES 2
Reply
Message 1 of 3
anwoj
444 Views, 2 Replies

How to execute command during other command

Hi,
I've just begun programming AutoCAD using .Net. Maybe answer to my question is trivial, but I can't figured out how to execute for eg. lisp command during executing other .net command.

After I add circle with SendStringToExecute there is no new circle in model space until the overriding "command1" command finishes.


My example code:

Public Class cadxClass
' Define command 'Asdkcmd1'
_
Public Sub Asdkcmd1()
Module1.aaa()
End Sub
End Class


Public Sub aaa()
Dim acadApp As Autodesk.AutoCAD.Interop.AcadApplication
Dim aDoc As Autodesk.AutoCAD.Interop.AcadDocument

Dim ed As Autodesk.AutoCAD.EditorInput.Editor = Application.DocumentManager.MdiActiveDocument.Editor

acadApp = CType(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication, Autodesk.AutoCAD.Interop.AcadApplication)

acadApp.Visible = True
aDoc = acadApp.ActiveDocument

Dim p1(2) As Double
p1(0) = 10
p1(1) = 10
p1(2) = 0

aDoc.ModelSpace.AddCircle(p1, 100)
MsgBox(aDoc.ModelSpace.Count.ToString)

Dim d As Autodesk.AutoCAD.ApplicationServices.Document
d = Application.DocumentManager.MdiActiveDocument
d.SendStringToExecute("_Circle" & vbCr & "30,30,0" & vbCr & "4" & vbCr, False, False, True)

MsgBox(aDoc.ModelSpace.Count.ToString)

End Sub
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: anwoj

>> I've just begun programming AutoCAD using .Net.

Right. And .NET is not VBA, and you shouldn't try to
use it like it was.

In this case, that means you don't use SendStringToExecute()
to send commands to AutoCAD, you write the code that will
create the objects you're trying to create using the API, and
not by executing commands.

Think of .NET as a very steep hill, which you are nearly at
the bottom of. Spend some time becoming familiar with
.NET and the AutoCAD .NET API, rather than just trying to
'port' VBA code that relies on kludges to get things done.

If you must execute commands, there's a better way to do
that in .NET, which has none of the problems that plague
SendStringToExecute().

Have a look here:

http://www.caddzone.com/CommandLine.vb


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5725447@discussion.autodesk.com...
Hi,
I've just begun programming AutoCAD using .Net. Maybe answer to my question is trivial, but I can't figured out how to execute for eg. lisp command during executing other .net command.

After I add circle with SendStringToExecute there is no new circle in model space until the overriding "command1" command finishes.


My example code:

Public Class cadxClass
' Define command 'Asdkcmd1'
_
Public Sub Asdkcmd1()
Module1.aaa()
End Sub
End Class


Public Sub aaa()
Dim acadApp As Autodesk.AutoCAD.Interop.AcadApplication
Dim aDoc As Autodesk.AutoCAD.Interop.AcadDocument

Dim ed As Autodesk.AutoCAD.EditorInput.Editor = Application.DocumentManager.MdiActiveDocument.Editor

acadApp = CType(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication, Autodesk.AutoCAD.Interop.AcadApplication)

acadApp.Visible = True
aDoc = acadApp.ActiveDocument

Dim p1(2) As Double
p1(0) = 10
p1(1) = 10
p1(2) = 0

aDoc.ModelSpace.AddCircle(p1, 100)
MsgBox(aDoc.ModelSpace.Count.ToString)

Dim d As Autodesk.AutoCAD.ApplicationServices.Document
d = Application.DocumentManager.MdiActiveDocument
d.SendStringToExecute("_Circle" & vbCr & "30,30,0" & vbCr & "4" & vbCr, False, False, True)

MsgBox(aDoc.ModelSpace.Count.ToString)

End Sub
Message 3 of 3
anwoj
in reply to: anwoj

Thanks for your help.

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