SendStringtoExecute and save

Michal_W
Contributor
Contributor

SendStringtoExecute and save

Michal_W
Contributor
Contributor

Hello

I have a serious problem with saving drawings that are modified using "sendstringtoexecute".

When my code only does the "sendstringtoexecute" commands, everything is fine, and AutoCad's manual closure of open drawings works.

'------------------------------------------

Dim p As Document

p = oApp.DocumentManager.Open("C:\Users\konta\Documents\dd.dwg", False)


p.SendStringToExecute("_-overkill" & vbCr & "_all" & vbCr & vbCr & vbCr, True, False, False)
p.SendStringToExecute("_Point" & vbCr & "1,1,0" & vbCr, True, False, False)
p.SendStringToExecute("_qsave" & vbCr, True, False, False)

'-----------------------------------------------------------

 

However, if he tries to add any form of closing the drawing to the source code, the drawings are closed but remain unchanged, which I made a few lines above, even if one of the "sendstringtoexecute" commands was "qsave". To close drawings, I tried to use:

1.

p.CloseAndDiscard

2.

Dim drawAcad As AcadDocument

drawAcad = p.GetAcadDocument
drawAcad.Close()

 

PS.

To avoid "COM Exception", or "Drawing is Busy" when closing drawings I have set comandsFlagon Sesion. As below

 

<CommandMethod("BMCzyszczenie", CommandFlags.Session)>

 

What can I do to save in drawings changes made with "sendstringto execute"

 

Thanks you in advance

Michal Wojcicki

0 Likes
Reply
Accepted solutions (2)
1,341 Views
2 Replies
Replies (2)

_gile
Mentor
Mentor
Accepted solution

SendStringToExcecute runs asynchronously, i.e. after all other instructions.

You can try to also close the document with SendStringToExecute:

 

 

p.SendStringToExecute("_close" & vbCr, True, False, False)

 

 

But if your code only scripts AutoCAD commands, it would be simpler to make a script and call it in a batch process with SciptPro 2.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes

Michal_W
Contributor
Contributor
Accepted solution

Thank you very much for the reply.

All clear.🙂

In my case it turned out to be more functional using the command "sendcommand"

0 Likes