Hello experts,
failing to export a number of idw-drawings to pdf, dwg and dxf-files by using a loop, I tried to do it a simpler way.
This very short and easy code should do it, as long as I am sure, that there are no other files opened than idws.
But there is an error occuring in the "oDoc.close" line.
Please give me a short advice, thank you.
Thomas
Anfang:oDoc=ThisDoc
oDoc.Save
iLogicVb.RunExternalRule("pdf_erstellen")
'iLogicVb.RunExternalRule("dwg_erstellen")
'iLogicVb.RunExternalRule("dxf_erstellen")
oDoc.Close
Goto Anfang
Solved! Go to Solution.
Solved by rossano_praderi. Go to Solution.
Hi Thomas,
I have three solutions, the simplest.
# 1 - could be your choice, setting the Boolean value specifying what to do when you close the document (save or not save)
# 2 - another method to close the document, included just for your information
Then I left on the code of the solution that I have chosen, the other two should work fine but I had some issues of application crashes.
'Anfang: 'Dim oControlDef As ControlDefinition 'Solution #2 'oControlDefs = ThisApplication.CommandManager.ControlDefinitions ' Solution #2 For Each oDrwDoc in ThisApplication.documents If oDrwDoc.DocumentType = kDrawingDocumentObject Then oDrwDoc.Save oDrwDoc.SaveAs(Replace(oDrwDoc.FullFileName, ".idw", ".pdf"), True) oDrwDoc.SaveAs(Replace(oDrwDoc.FullFileName, ".idw", ".dwg"), True) oDrwDoc.SaveAs(Replace(oDrwDoc.FullFileName, ".idw", ".dxf"), True) 'iLogicVb.RunExternalRule("pdf_erstellen") 'iLogicVb.RunExternalRule("dwg_erstellen") 'iLogicVb.RunExternalRule("dxf_erstellen") 'oControlDefs.Item("AppFileCloseCmd").Execute ' Solution #2 'oDrwDoc.Close(False) ' Solution #1 End If Next ThisApplication.documents.closeall(False) ' My choice 'Goto Anfang
Bregs
Rossano Praderi
Hi Rossano,
I am sorry, that I made you much more work than necessary. I should have mentioned, that I am a bloody beginner with iLogic and also struggling with the English language ( I am german - but learning ).
I should have erased that "save" line, because this was only for updating the idw using an automatic rule, that is started when I save an idw. So it is not necessary to check before just doing it ( or call that rule directly ).
But, in result, your code works very good as it is :-))
With your working loop even the "close" line becomes obsolete. I only tried to get the focus to the next open drawing. I didnĀ“t really want to close these files ( but it was not a problem either and good control for the progress while they disappear ).
Thank you so much, very good job.
Best regards
Thomas
P. S.: My next duty is to check my export rules, because the loop is getting terminated when I activate the calling lines.
Again, your code works fine, but I want to export to different folders and these rules do work fine when I use them separately
I think, that I have to check double dimension commands touching the same variables, right? Never found a hint about the declaration level of variables in iLogic. Are they local, global or on any other level?
Hi Thomas,
@tschuette wrote:Hi Rossano,
I am sorry, that I made you much more work than necessary. I should have mentioned, that I am a bloody beginner with iLogic and also struggling with the English language ( I am german - but learning ).
I added a few lines of code just to show you an example of how to use a loop, I do not know what your level of knowledge on programming and then I thought to give you one more example on how to do it (I'm Italian and my English is worse than yours, i'm learning too)
I should have erased that "save" line, because this was only for updating the idw using an automatic rule, that is started when I save an idw. So it is not necessary to check before just doing it ( or call that rule directly ).
Ok!
---------only regarding my code----------
Anyway for your information, all the conditional statements in my code are necessary for the correct execution.
Without checking the "DocumentType" you will get an error, even if you run my code inside of Drawing Documents (.idw).
--------not anymore regarding my code---------
But, in result, your code works very good as it is :-))
Thank you
With your working loop even the "close" line becomes obsolete. (Ok) I only tried to get the focus to the next open drawing. I didnĀ“t really want to close these files ( but it was not a problem either and good control for the progress while they disappear ). (Ok)
Thank you so much, very good job.
Best regards
Thomas
You are welcome, thank you for your kindly compliments.
P. S.: My next duty is to check my export rules, because the loop is getting terminated when I activate the calling lines.
Again, your code works fine, but I want to export to different folders and these rules do work fine when I use them separately
I think, that I have to check double dimension commands touching the same variables, right? Never found a hint about the declaration level of variables in iLogic. Are they local, global or on any other level?
I'm not sure, do you like to add a new location folder for each format (pdf,dwg,dxf)?
This is easy to implement.
Don't be mad with me, but I think it's better if you open a new thread with more detailed requirements.
Cheers
Rossano
Hi Rossano,
you wrote
I'm not sure, do you like to add a new location folder for each format (pdf,dwg,dxf)?
This is easy to implement.
Don't be mad with me, but I think it's better if you open a new thread with more detailed requirements.
I am sure, that it is easy for you š
I am going to open a new thread with my three rules patched together from several sources in the web.
CU
Thomas
Hi Thomas,
thank you for your reply.
I'm looking forward to follow yours new post.
I'm glad to be helpful and i will be happy to help you again.
Bregs
Rossano