Question about adding drawing template with code

Question about adding drawing template with code

frederic.vandenplas
Collaborator Collaborator
531 Views
5 Replies
Message 1 of 6

Question about adding drawing template with code

frederic.vandenplas
Collaborator
Collaborator

Hi,

 

I've recently discovered that another template opens when i use this code, previously only Standard.idw was in the template folder, now i have added another one with a name (alphabetically before Standard.idw (for example NewTemplate.idw)

 

Dim oDrawDoc As DrawingDocument = InvApp.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, InvApp.FileManager.GetTemplateFile(DocumentTypeEnum.kDrawingDocumentObject) 

Is this as designed that through API, the first drawing (alphabetically) , will be the template used by this line of code.

 

I know how to avoid this and define the template path string, so i don't need any code 🙂

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
532 Views
5 Replies
Replies (5)
Message 2 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @frederic.vandenplas,

 

A new template is created and called it as "NewStandard.idw".

 

Template.jpg

 

On running following VBA code,

 

MsgBox (ThisApplication.FileManager.GetTemplateFile(kDrawingDocumentObject))

A message box is popped up and showing the path of "Standard.idw".

 

TemplatePath.JPG

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 6

frederic.vandenplas
Collaborator
Collaborator

Hi,

 

if i use your/my code, this is what i get, so it's more a random thing?

This is not expected behaviour if you compare it to the GUI

Knipsel.JPG

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 4 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @frederic.vandenplas,

 

Drawing template path can be changed to desired location.

 

Go to "Tools" tab -> click on "Application Options" button -> a dialog will appear. In that, click on "File" tab -> under "Default Templates" -> template can be changed to desired location as shown in below image.

 

TemplateFile.jpg

 

After changing template path, click on "General" tab -> under "Startup" -> check "Startup action"-> enable "New from template", new template can be specified from template path.

 

 

NewTemplate.jpg

 

On running following VBA code

 

MsgBox (ThisApplication.FileManager.GetTemplateFile(kDrawingDocumentObject))

Following message box will appear with new template path.

 

NewTemplatePath.JPG

 

Please feel free to contact if there is any doubt.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 6

frederic.vandenplas
Collaborator
Collaborator

Hi @chandra.shekar.g

 

I understand your explanation, but what if i don't use a startup action, and i really don't use it in real life situations!

 

On the other hand, if i don't use this settings, api does not look at these settings too, because suddenly my code opens the "wrong" template.

 

So there must be an api explanation for this strange behaviour???

 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 6 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @frederic.vandenplas,

 

Even after disabling Startup action, template file path can be retrieved from the VBA code.

 

 

ThisApplication.FileManager.GetTemplateFile(kDrawingDocumentObject)

 

Please find the following API to play with startup action settings.

 

 

ThisApplication.GeneralOptions.StartupActionType = kNoStartupAction
    
ThisApplication.GeneralOptions.StartupNewFileTemplateName = ""
    
ThisApplication.GeneralOptions.StartupProjectFileName = ""

Please feel free to contact if there is any doubt.

 

If solves your problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,

 


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes