Inventor Customization

Inventor Customization

Reply
Contributor
jgaston
Posts: 18
Registered: ‎11-14-2003
Message 1 of 5 (1,247 Views)
Accepted Solution

Create a new Inventor DWG drawing using VB.NET

1247 Views, 4 Replies
07-08-2011 04:14 AM

Hello.

 

I'm trying to create a new DWG file in Inventor.

 

In the Inventor options I changed the default file type of drawing, but when I add a new document using the Add method from the Documents collection, always creates a file of type IDW.

 

I tried to force the option from code, but I get the same result.

 

I am using VB.net 2008 and Inventor 2010, this is the code:

 

InvApp = InventorGet()

InvApp.Visible = True

InvApp.DrawingOptions.DefaultDrawingFileType = DefaultDrawingFileTypeEnum.kDWGDefaultDrawingFileType

InvDoc = InvApp.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject)

 

Any ideas? Thanks in advance

 

Hi jgaston

Here is an exaple how you can use the standard templates:

 

first set the option: DrawingOptions.DefaultDrawingFileType = kDWGDefaultDrawingFileType

then get your template: FileManager.GetTemplateFile(kDrawingDocumentObject, kDefaultSystemOfMeasure, kDefault_DraftingStandard, "{BBF9FDF1-52DC-11D0-8C04-0800090BE8EC}")

 

use this template in the way i mentioned:

Documents.Add(kDrawingDocumentObject, TemplateNameDWG, True)

 

Example:

This code will add two new drawing douments to inventor. One dwg, one idw.

 

Dim InvApp As Application
Set InvApp = ThisApplication

'Get name of DWG Tamplate
InvApp.DrawingOptions.DefaultDrawingFileType = kDWGDefaultDrawingFileType
Dim TemplateNameDWG As String
TemplateNameDWG = InvApp.FileManager.GetTemplateFile(kDrawingDocumentObject, kDefaultSystemOfMeasure, kDefault_DraftingStandard, "{BBF9FDF1-52DC-11D0-8C04-0800090BE8EC}")

'Get name of idw template
InvApp.DrawingOptions.DefaultDrawingFileType = kIDWDefaultDrawingFileType
Dim TemplateNameIDW As String
TemplateNameIDW = InvApp.FileManager.GetTemplateFile(kDrawingDocumentObject, kDefaultSystemOfMeasure, kDefault_DraftingStandard, "{BBF9FDF1-52DC-11D0-8C04-0800090BE8EC}")

'New DWG
Dim oDocDWG As Document
Set oDocDWG = InvApp.Documents.Add(kDrawingDocumentObject, TemplateNameDWG, True)

'New IDW

Dim oDocIdw As Document
Set oDocIdw = InvApp.Documents.Add(kDrawingDocumentObject, TemplateNameIDW, True)

 

 

I hope this works for you.

Product Support
Dennis.Ossadnik
Posts: 34
Registered: ‎05-11-2011
Message 2 of 5 (1,239 Views)

Re: Create a new Inventor DWG drawing using VB.NET

07-08-2011 06:18 AM in reply to: jgaston

Hi jgaston,

you could use it like that and specify the template file:

 

Dim InvDoc As Document 

Set InvDoc = InvApp.Documents.Add(kDrawingDocumentObject, "C:\Templates\Norm.dwg", True)

 

Hope, this helps.




Dennis Ossadnik


______________________________________________________________

If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!

Contributor
jgaston
Posts: 18
Registered: ‎11-14-2003
Message 3 of 5 (1,226 Views)

Re: Create a new Inventor DWG drawing using VB.NET

07-11-2011 12:31 AM in reply to: Dennis.Ossadnik

Thanks Dennis, but hoped to use the default template and not have to deal with code to manage the routes.

If I understand, the help of the API says the method should work this way.

Regards

 

api.JPG

 

 

Product Support
Dennis.Ossadnik
Posts: 34
Registered: ‎05-11-2011
Message 4 of 5 (1,223 Views)

Re: Create a new Inventor DWG drawing using VB.NET

07-11-2011 01:02 AM in reply to: jgaston

Hi jgaston

Here is an exaple how you can use the standard templates:

 

first set the option: DrawingOptions.DefaultDrawingFileType = kDWGDefaultDrawingFileType

then get your template: FileManager.GetTemplateFile(kDrawingDocumentObject, kDefaultSystemOfMeasure, kDefault_DraftingStandard, "{BBF9FDF1-52DC-11D0-8C04-0800090BE8EC}")

 

use this template in the way i mentioned:

Documents.Add(kDrawingDocumentObject, TemplateNameDWG, True)

 

Example:

This code will add two new drawing douments to inventor. One dwg, one idw.

 

Dim InvApp As Application
Set InvApp = ThisApplication

'Get name of DWG Tamplate
InvApp.DrawingOptions.DefaultDrawingFileType = kDWGDefaultDrawingFileType
Dim TemplateNameDWG As String
TemplateNameDWG = InvApp.FileManager.GetTemplateFile(kDrawingDocumentObject, kDefaultSystemOfMeasure, kDefault_DraftingStandard, "{BBF9FDF1-52DC-11D0-8C04-0800090BE8EC}")

'Get name of idw template
InvApp.DrawingOptions.DefaultDrawingFileType = kIDWDefaultDrawingFileType
Dim TemplateNameIDW As String
TemplateNameIDW = InvApp.FileManager.GetTemplateFile(kDrawingDocumentObject, kDefaultSystemOfMeasure, kDefault_DraftingStandard, "{BBF9FDF1-52DC-11D0-8C04-0800090BE8EC}")

'New DWG
Dim oDocDWG As Document
Set oDocDWG = InvApp.Documents.Add(kDrawingDocumentObject, TemplateNameDWG, True)

'New IDW

Dim oDocIdw As Document
Set oDocIdw = InvApp.Documents.Add(kDrawingDocumentObject, TemplateNameIDW, True)

 

 

I hope this works for you.




Dennis Ossadnik


______________________________________________________________

If my post answers your question, please click the "Accept as Solution" button. This helps everyone find answers more quickly!

Contributor
jgaston
Posts: 18
Registered: ‎11-14-2003
Message 5 of 5 (1,218 Views)

Re: Create a new Inventor DWG drawing using VB.NET

07-11-2011 01:35 AM in reply to: Dennis.Ossadnik

Thank you very much Denis

I manage with this.

Just one question, the GUID "{BBF9FDF1-52DC-11D0-8C04-0800090BE8EC}" what type of document referred to? where I can find a list of GUID's valid for this function?

Best regards and thank you very much again.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.