Get the objects inside sketch in part document

Get the objects inside sketch in part document

prince_satyam
Participant Participant
315 Views
3 Replies
Message 1 of 4

Get the objects inside sketch in part document

prince_satyam
Participant
Participant

I want to get the name of objects (like Reference 25, 26 etc) inside sketch in a part document as shown in the given fig. Can anyone provide a macro/C# code to get it? I'm using inventor 2020.

prince_satyam_0-1727253043379.png

 

0 Likes
316 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @prince_satyam.  That is a pretty complicated one.  Why do you need to get those names?  Have you tried exploring within the PlanarSketch.ProjectedCuts collection yet?  Each ProjectedCut object in the collection has a 'Name' property you can review.  If that does not give you the results you were looking for, then the next thing you can look into is checking the PlanarSketch.HasReferenceComponent property, and if true, then use its PlanarSketch.ReferenceComponent property to get that, and inspect it.  Then there is also the PlanarSketch.ReferencedEntity property, which will return another PlanarSketch in 'derived' situations.  However, if the other sketch only exists within an assembly, and that assembly is not currently open, then it may not be able to find what you are looking for.

 

Generally speaking, parts do not contain 'links' (references) to any of the assemblies or drawings they may be referenced within.  Only the assemblies or drawings which reference that part will contain those references.  Similarly, even if a part is being referenced by a ton of other assemblies and drawings, the part's Document.ReferencingDocuments property will only be able to find the ones that are currently open within Inventor at that moment...not any of the others, because there is no record of those associations saved within the part itself.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

prince_satyam
Participant
Participant

Hi @WCrihfield, Thanks for your suggestions but I have already tried all the apis you have mentioned asnd didn't got the required details. Is there anything else I can try?

 

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Hi @prince_satyam.  I am not sure that this will be possible right now.  Have a look at this other recent, similar forum discussion, where they asked nearly the same question.

https://forums.autodesk.com/t5/inventor-programming-ilogic/where-part-model-stores-the-name-of-assem... 

The Autodesk software developer who replied in Message 4 of that discussion is extremely knowledgeable in the area of Inventor's API, and has likely been involved in this forum since its inception.  If he does not know how to get that information from within a part using Inventor's API code, then it is most likely that no one does, or it may simply not be possible right now.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes