VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SendStringToExecute Synchronous

4 REPLIES 4
Reply
Message 1 of 5
galbori
1627 Views, 4 Replies

SendStringToExecute Synchronous

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?

 

4 REPLIES 4
Message 2 of 5
Alfred.NESWADBA
in reply to: galbori

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 5
galbori
in reply to: galbori

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


Message 4 of 5
Alfred.NESWADBA
in reply to: galbori

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 5
galbori
in reply to: galbori

Thanks a lot Alfred

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

Post to forums  

Autodesk Design & Make Report

”Boost