Drawing won't save after creation with template

Drawing won't save after creation with template

miechh
Collaborator Collaborator
775 Views
4 Replies
Message 1 of 5

Drawing won't save after creation with template

miechh
Collaborator
Collaborator

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)
0 Likes
Accepted solutions (1)
776 Views
4 Replies
Replies (4)
Message 2 of 5

Vladimir.Ananyev
Alumni
Alumni

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

0 Likes
Message 3 of 5

miechh
Collaborator
Collaborator

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)
0 Likes
Message 4 of 5

Vladimir.Ananyev
Alumni
Alumni

I suspected something similar to this.

My congratulations!


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 5

miechh
Collaborator
Collaborator
Accepted solution
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)
0 Likes