Get Template Name of Current File

Get Template Name of Current File

seabrahenrique
Advocate Advocate
1,685 Views
5 Replies
Message 1 of 6

Get Template Name of Current File

seabrahenrique
Advocate
Advocate

Guys,

 

I searched for here, but i can't finded a simple way to capture name of current template (.dwt) by a VBA code...

 

Any ideas?

 

Tks in advance!

0 Likes
Accepted solutions (2)
1,686 Views
5 Replies
Replies (5)
Message 2 of 6

norman.yuan
Mentor
Mentor
Accepted solution

Do you mean you want to get the same template file information as "Options...->File tab -> Template Settings -> Drawing template location/Default Template File Name for QNEW"?

 

In this case, you can get the information via Application.Preferences (AcadPreferences).Files(AcadPreferenceFiles).TemplateFilePath/TemplateDwgPath.

 

Note: TemplateDwgPath could be empty, if the user's profile does not have this path set.

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 6

seabrahenrique
Advocate
Advocate

Thanks for the answer @norman.yuan !

 

Almost that...

 

What i need exataly isn't the configuration template by user... but what themplate (.dwt) the user choose when started the project, with the "NEW" option, for example...

 

I want to make something that when the user open my form, it alert if they was working in wrong template, u know?

 

For this i want to know: Wath the current template of this drawing? How to get this (name or path) with a vba code?

 

I hope it was clear 🙂

0 Likes
Message 4 of 6

norman.yuan
Mentor
Mentor
Accepted solution

Well, once a new drawing is created, it does not remember which template is is based on. So, there is no way to know that. 

 

In your case, it is not important to know which template is used: user could use the template to create a new drawing, and then create more new drawings based one the first new drawing: are you going to say the later new drawings are based on wrong template? What you need to do, before your form is showing, is to validate the pre-existing content are there, such as layers, text/dim styles.... In this case, you can examine/compare each type of content against a particular drawing (template or not, does not matter here). Hopefully, you only do minimum of this; or you need something like "Cad standard comparison" type of work.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 6

seabrahenrique
Advocate
Advocate

You're right about that... i was complicating the uncomplicated i guess 😛


Thanks! I'll do this!

0 Likes
Message 6 of 6

seabrahenrique
Advocate
Advocate

The first answer also helped me here....

 

Just to add, i used a variation of your sugestion: "Application.Preferences.Files.QNewTemplateFile" and worked perfect 🙂

0 Likes