Does any part or assembly have an ID?

Does any part or assembly have an ID?

comic3344
Enthusiast Enthusiast
1,343 Views
10 Replies
Message 1 of 11

Does any part or assembly have an ID?

comic3344
Enthusiast
Enthusiast

Dear all,

I am so sorry to repost the problem in the Inventor Customization Forum.

The picture below can help me to describe my problem.

IDproblem.png

part1 and part2 are from the same ipt file, so the imformations between the two parts are almost same.
In the project, the name of part2 will be "part:1". If the project is a small one, OK, I can match it manually.
But the Assembly A may have thousands of subAssemblies and parts. -_-
Thus, a particular parameter is needed, such as an ID, to show the differences with the parts from the same ipt file.
I tried to use the hashcode, but the codes may be different when I output the code every time.
I hope there is a code to show uniqueness in Inventor like Revit.
In Revit, every element have an elementID, even the element is created from the same family.
Please help me, Thank you!

0 Likes
1,344 Views
10 Replies
Replies (10)
Message 2 of 11

dgreatice
Collaborator
Collaborator

hi,

 

I think you can use internal name.

 

you cant find in:

Document.Definition.InternalName

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 3 of 11

HermJan.Otterman
Advisor
Advisor

In Inventor Cable and Harness you have something like this, and it is called RefDes.

but sadly it is not supported by the API.

attributes are used, you can see that, but the real RefDes name should be somewhere in the Harness assembly...

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 4 of 11

Martin-Winkler-Consulting
Advisor
Advisor

Hi @comic3344

as @dgreatice wrote you can use the InternalName. The InternalName doesn't change.

For having a closer look to your issue this vba code may be usefull:

Public Sub AssemblySample()
    ' Get the active assembly.
    Dim oAsmDoc As AssemblyDocument
    Set oAsmDoc = ThisApplication.ActiveDocument
    Debug.Print oAsmDoc.DisplayName
 
    ' Call the function that does the recursion.
    Call Assembly(oAsmDoc.ComponentDefinition.Occurrences, 1)
End Sub
 
Private Sub Assembly(Occurrences As ComponentOccurrences, _
                             Level As Integer)
    ' Iterate through all of the occurrence in this collection.  This
    ' represents the occurrences at the top level of an assembly.
    Dim oOcc As ComponentOccurrence
    For Each oOcc In Occurrences
        ' Print the name of the current occurrence.
        Debug.Print Space(Level * 3) & oOcc.Name
        Debug.Print Space(Level * 3) & "InternalName:" & oOcc.Definition.Document.InternalName
        Debug.Print Space(Level * 3) & "RevisionID:" & oOcc.Definition.Document.RevisionId
        Debug.Print Space(Level * 3) & "DatabaseRevisionID:" & oOcc.Definition.Document.DatabaseRevisionId
        Debug.Print Space(Level * 3) & "ModelGeometryVersion:" & oOcc.Definition.ModelGeometryVersion
        Debug.Print "=============================================================================================="
 
        ' Check to see if this occurrence represents a subassembly
        ' and recursively call this function to traverse through it.
        If oOcc.DefinitionDocumentType = kAssemblyDocumentObject Then
            Call Assembly(oOcc.SubOccurrences, Level + 1)
        End If
    Next
End Sub

It's from this german post written by @Juergen_Wagner

Regards

 

Martin Winkler
CAD Developer
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.


EESignature

0 Likes
Message 5 of 11

comic3344
Enthusiast
Enthusiast

Dear @Martin-Winkler-Consulting and @dgreatice, thanks to your reply.

I tried to use internalname, but the output code is same with the parts from the same ipt file.

With this code, the unique part in the model cannot be identitied. 

0 Likes
Message 6 of 11

Martin-Winkler-Consulting
Advisor
Advisor

@comic3344

Try a combination of InternalName (in all parts equal) and RevisionID that has to be differrent in all parts copied from part1

Martin Winkler
CAD Developer
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.


EESignature

0 Likes
Message 7 of 11

comic3344
Enthusiast
Enthusiast

Thanks to your idea. I tried, but many parts have the same Internalname and RevisionId. -_-

0 Likes
Message 8 of 11

HermJan.Otterman
Advisor
Advisor

The "oDoc._PrimaryDeselGUID" seems to be different for all occurrences, but it also seems to change constantly,

can you do something with attributes on the occurrences?

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 9 of 11

comic3344
Enthusiast
Enthusiast

Inventor may focus on the part document, not on the part instance.  

 

I tried the "_PrimaryDeselGUID", but some Exception came out. 

 

And I the key word "_PrimaryDeselGUID" is not in the API file either.

0 Likes
Message 10 of 11

BrianEkins
Mentor
Mentor

Your original question doesn't make sense to me.  How can Part1 and Part2 be from same ipt file?  Do you mean you have a part file called Part.ipt and in the assembly, you've placed it twice so now you have Part:1 and Part:2?  If that's true, I'm still having a hard time understanding what you're trying to do.

 

Assuming what I've said above is true what you have is Assembly A that is referencing Part.ipt.  It has two occurrences of Part.ipt.  The same is true for Assembly A; it is also referencing Part.ipt and also happens to have two occurrences.  Assembly B doesn't know anything about Assembly A.  Also, Part.ipt doesn't know how it's used.  Assembly A and B both know that they use Part.ipt, but Part.ipt doesn't know who's referencing it.  You would have to somehow know about this relationship some other way.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 11 of 11

dgreatice
Collaborator
Collaborator

Hi,

 

I think, difference part have difference internal name, please double check if you have same part(but you change occurrence name), that will be same internal name.

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes