- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
Blog: hjalte.nl - github.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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")
Alternatively if you know the exact path of the weldment document you can load this directly.
Or if this helped you, please, click (like)
Regards
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
Or if this helped you, please, click (like)
Regards
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
It is strange that I test below 4 templates and only the "Weldment.iam" template cannot show the path.
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!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
Below is the folder.
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!