Define oDoc by Part name in Assembly

Define oDoc by Part name in Assembly

mk92
Collaborator Collaborator
365 Views
2 Replies
Message 1 of 3

Define oDoc by Part name in Assembly

mk92
Collaborator
Collaborator

Hello,

 

i cant find the way to define oDoc by the part name in an assembly.

 

Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.Documents.ItemByName(ThisDoc.WorkspacePath()+"\Test.ipt") 

I need this without the WorkspacePath. 

0 Likes
366 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable

Do you mean get the document from an occurence of a part in an assembly? Something like this:

 

Inventor.AssemblyDocument oAsemDoc = (Inventor.AssemblyDocument)oInvApp.ActiveDocument;
Inventor.ComponentOccurrence oCompOcc = oAsemDoc.ComponentDefinition.ActiveOccurrence; //or however you determine the part you are looking for
Inventor.PartDocument oInvDoc = oCompOcc.Definition.Document;

0 Likes
Message 3 of 3

mk92
Collaborator
Collaborator

I need to do this:

 

Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.Documents.ItemByName(ThisDoc.WorkspacePath()+"\Test.ipt") 

Dim oCompDef As PartComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

Dim oSketch As PlanarSketch
oSketch = oCompDef.Sketches.Item("Sketch1")

Without the WorkspacePath. I want to work with Sketch 1 from the part named Test.ipt.

 

Like:

oPartDoc = ThisApplication.Documents.ItemByName("Test:1") 

So i want to use its Browser Name instead of its Path and Filename.

0 Likes