Inventor API Object Model Questions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I hope I ask this question correctly because I'm still very confused about using the Inventor API Object Model correctly. Lets say I setup a class to launch Inventor like this:
class LaunchInventor { public Inventor.Application vInvApp { get; set; } public Inventor.Document vInvDoc { get; set; } public LaunchInventor() { try { // Check for instance of AutoCAD vInvApp = (Inventor.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"); } catch (Exception) // if none found start a new instance of Inventor { vInvApp = (Inventor.Application)System.Activator.CreateInstance(System.Type.GetTypeFromProgID("Inventor.Application")); } if (vInvApp != null) { vInvApp.Visible = true; vInvApp.WindowState = Inventor.WindowsSizeEnum.kMaximize; } } }
So if I understand it correctly, and apparently I don't, I should now be able to use the vInvApp object to create a new PartDocument. As I look at the API Object Model I see that PartDocument is under Documents which is under Application. But to create a new PartDocument I have to do this:
PartDocument partDoc = (PartDocument)vInvApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, vInvApp.FileManager.GetTemplateFile(DocumentTypeEnum.kPartDocumentObject));
So my thinking that I could do something like:
PartDocument pDoc1 = vInvApp.Documents.PartDocument.Add(xxxxxxx)
Is nothing like the required syntax. I'm still learning this API but what am I doing wrong in thinking that I'd just use "." to access the properties deeper down in the model. Suddenly there is this thing with parenthesis which I'm not quite following yet. As when do I need to use parenthesis vs the period?