SendStringToExecute Synchronous

SendStringToExecute Synchronous

Anonymous
Not applicable
2,276 Views
4 Replies
Message 1 of 5

SendStringToExecute Synchronous

Anonymous
Not applicable

I'm trying to convert by cide a lot of mechanical dwg by code.

Unfortunatly the method saveas (acDoc.Database.SaveAs) is not completly working with mechanical drawing (Mechanical 2010), so I'm trying to use SendStringToExecute command.

Unfortunatly SendStringToExecuteis not synchronous, so the instruction after SendStringToExecute (acDoc.CloseAndDiscard) is executed before the SendStringToExecute is completed.

How can I understand when the SendStringToExecute command is completed?

 

0 Likes
2,277 Views
4 Replies
Replies (4)
Message 2 of 5

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> How can I understand when the SendStringToExecute command is completed?

Split your code into two procedures

 

Sub A

...run any code

...define EventHandler for CommandEnded or reachedQuiescentState that addresses to be handled by Sub B

...SendCommand("_SAVE" & vbnewline)

End Sub A

 

Sub B

...do your close or whatever has to be done after savign

...

End Sub B

 

Good luck, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks for your answer Alfred, but I would like using  SendStringToExecute not SendCommand and what do you mean with

...define EventHandler for CommandEnded or reachedQuiescentState that addresses to be handled by Sub B

 

I don't know CommandEnded

In vbNET I use                         AddHandler <object>, AddressOf saveDWG and I cannot find a object CommandEnded


0 Likes
Message 4 of 5

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

as long as you start a VB.NET-defined command you can't start any commands in it (as long as these command are not handled as transparent commands). So it's SendCommand or SendStringToExecute or any P/Invoke versions, it does not matter, the thing is "a command is running". A CIRCLE-command can't run inside a LINE-command

 

 

>> I don't know CommandEnded

>> In vbNET I use

 

Dim pAcadDoc As ApplicationServices.Document = ApplicationServices.Application.DocumentManager.MdiActiveDocument
AddHandler pAcadDoc.CommandEnded, AddressOf ....

 - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 5

Anonymous
Not applicable

Thanks a lot Alfred

0 Likes