Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Drawing won't save after creation with template

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
miechh
604 Views, 4 Replies

Drawing won't save after creation with template

I'm trying to automate the drawing-creation in our company. Steps I've taken:

- create new drawingdocument with template

- Save new drawingdocument

 

Problem:

Creation of new document works, but the next step, saving it to a specific location, fails. Error handler is initiated and displays error: Invalid procedure call or argument.

 

Used code:

 

Dim DXF_DWG as DrawingDocument
'Create new drawing based on template
Set DXF_DWG = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, ThisApplication.FileOptions.TemplatesPath & "\Folded and Flatpattern DXF.dwg", True)

'Save new drawing to specific location Call DXF_DWG.SaveAs("C:\Temp\Test.dwg", False)

 

As told, the VB-code raises an error on the last command. What am I doing wrong? What are the correct steps in VBA to create a new drawing document based on a template and save the newly created drawing to a desired location?


Product Design Suite 2024
Inventor 2024 (v 28.20.27200.0000), Vault Basic 2024
Fusion 360
HP Workstation Z4
Intel Xeon 3.4GHz
32GB RAM
Windows 10 Professional (64bit)
4 REPLIES 4
Message 2 of 5
Vladimir.Ananyev
in reply to: miechh

Your code is correct and works fine with my templates. 

Can you upload your  Folded and Flatpattern DXF.dwg ?


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 5
miechh
in reply to: Vladimir.Ananyev

Vladimir,

 

Thanks for your response. You said my code was correct, that's good for my confidence! Smiley Wink. I just found out what may have caused the problem. There was some VBA-code in the template (triggered on Save event). The template is a copy of another template in which a dialog will pop up asking the user in what state the drawing is (preliminary, final, etc.) when saving the drawing. This code was still present in the dxf-dwg template, and probably caused the problem. I removed the VB-code in the template and now it's working fine. Only thing I've come across is the dialog window showing up during the SaveAs command; asking me to save the dependant files. Still have to click on "yes to all" and "OK".


Product Design Suite 2024
Inventor 2024 (v 28.20.27200.0000), Vault Basic 2024
Fusion 360
HP Workstation Z4
Intel Xeon 3.4GHz
32GB RAM
Windows 10 Professional (64bit)
Message 4 of 5
Vladimir.Ananyev
in reply to: miechh

I suspected something similar to this.

My congratulations!


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 5 of 5
miechh
in reply to: Vladimir.Ananyev

Sometimes you're stuck in your brain, but when you've had some sleep at night, the next day you see the light! 😉 Also used the Save2-procedure to eliminate the user interaction. Everything is working now.

Product Design Suite 2024
Inventor 2024 (v 28.20.27200.0000), Vault Basic 2024
Fusion 360
HP Workstation Z4
Intel Xeon 3.4GHz
32GB RAM
Windows 10 Professional (64bit)

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

Post to forums  

Autodesk Design & Make Report