Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
jingying_1213
454 Views, 6 Replies

Create a new Weldment type document?

Hi All,

 

I tried to create a new "Weldment type" assembly document using below codes.  It did create a new assembly document but it was not "Weldment type".

 

Could someone know where is the problem? Thanks!

 

Sub Main()	
	Dim oDocs As Documents = ThisApplication.Documents
	
	'THIS IS A WELDMENT SUB TYPE
	Dim oWeldment As String = "{28EC8354-9024-440F-A8A2-0E0E55D635B0}"
	
	Dim oTemplateFile As String = ThisApplication.FileManager.GetTemplateFile(kAssemblyDocumentObject, _
	kDefaultSystemOfMeasure, kDefault_DraftingStandard, oWeldment)
	
	Dim oADoc As Document = oDocs.Add(kAssemblyDocumentObject, oTemplateFile, True)	
End Sub

 

 

JelteDeJong
in reply to: jingying_1213

The method "GetTemplateFile" will not make a weldment document but will just point to the weldment template. Therefore you need to check that your template is a weldment template. Therefore you could add a message box and look if the method really points to a weldment assembly.

        Dim oWeldment As String = "{28EC8354-9024-440F-A8A2-0E0E55D635B0}"

        Dim oDocs As Documents = ThisApplication.Documents
        Dim oTemplateFile As String = ThisApplication.FileManager.GetTemplateFile(DocumentTypeEnum.kAssemblyDocumentObject,
            SystemOfMeasureEnum.kDefaultSystemOfMeasure, DraftingStandardEnum.kDefault_DraftingStandard, oWeldment)

        MsgBox(oTemplateFile)

        Dim oADoc As Document = oDocs.Add( DocumentTypeEnum.kAssemblyDocumentObject, oTemplateFile, True)

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

A.Acheson
in reply to: jingying_1213

In testing if the en-US folder is present and there is no no Weldment.iam file then this will default to a regular Assembly or the kAssemblyDocumentObject  because no subtype document is available. This also happens if the standard name "Weldment.iam" is not used. In your case it might be the case that the default name is not being used. You can test the path and if no path is shown then this will default to the kAssemblyDocumentObject.

 

MessageBox.Show(oTemplateFile, "Template Path")  

 

AAcheson_0-1665858972636.png

 

Alternatively if you know the exact path of the weldment document you can load this directly.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
jingying_1213
in reply to: JelteDeJong

 

I add a message box and it shows blank. 

 

There is no issue when I try to add other template.

 

I also confirm that the Weldment.iam template is in the correct path.

 

jingying_1213_0-1665890333450.png

 

A.Acheson
in reply to: A.Acheson

Can you confirm if there is a folder called en-US in the templates folder? In my testing if the weldment file is not in this folder but in the templates folder (1 level up)  then the function will not find the path. If the en-US folder is removed then the function will search and find the weldment file in the templates folder. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
jingying_1213
in reply to: A.Acheson

Hi,

 

It is strange that I test below 4 templates and only the "Weldment.iam" template cannot show the path.

 

jingying_1213_0-1665893908095.png

 

However, like you said, when I use the exact path of the "Weldment.iam" template, the correct weldment assembly is created. This is an alternative way and it works well but I still want to know where is the problem.

 

Thanks!!

jingying_1213
in reply to: A.Acheson

Hi, I have a "zh-CN" in my template folder not "en-US" because I use the Chinese version Inventor. 

 

Below is the path of template.

 

jingying_1213_0-1665920967940.png

 

Below is the folder.

 

jingying_1213_1-1665921032842.png

All templates are in this folder, I tried the 4 templtes highlighted in yellower, all are ok using those codes except the Weldment.iam. That is the issue.

 

Thanks!