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

SendStringtoExecute and save

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Michal_W
1196 Views, 2 Replies

SendStringtoExecute and save

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

2 REPLIES 2
Message 2 of 3
_gile
in reply to: Michal_W

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

Message 3 of 3
Michal_W
in reply to: _gile

Thank you very much for the reply.

All clear.🙂

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

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report