iLogic to read a part's Z offset occurrence value in an assembly.

iLogic to read a part's Z offset occurrence value in an assembly.

jasperpuss
Contributor Contributor
690 Views
4 Replies
Message 1 of 5

iLogic to read a part's Z offset occurrence value in an assembly.

jasperpuss
Contributor
Contributor

Hi all, I was wondering if there is any way to create an Inventor ilogic component which can read the Z value of it's occurrence offset when placed in an assembly.  I would then emboss the text of the value so that the part displayed it's own level. I would then use the parts to display their level above or below a datum to then show up on a subsequent drawing.  Any help would be much appreciated.

 

Note, in the picture attached, the part I am referring to is the triangle with embossed text above it.

 

Cheers,

Andrew

0 Likes
691 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @jasperpuss.  That data can be a bit complicated to get to, because it involves a Matrix object.  The ComponentOccurrence object has a Property called Transformation that returns this Matrix, which contains the data about the component's position and orientation within the 3D model space of the assembly.  Without going into tons of details, the position of the data within that Matrix that contains the Z-offset data you are looking for is in row 3, column 4.  Here is a simple iLogic rule that will display that little bit of data about any 'top level' component you pick.  Keep in mind that the number returned is in centimeters by default, so if you need it in inches or some other units, you will have to either do some math or convert it to the units you want.

 

oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a component.")
If IsNothing(oObj) Then Exit Sub
If Not TypeOf oObj Is ComponentOccurrence Then Exit Sub
Dim oOcc As ComponentOccurrence = oObj
oZOffset = oOcc.Transformation.Cell(3, 4)
MsgBox("Z Offset = " & oZOffset,,"")

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡 or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5

andy.bostock
Explorer
Explorer

Hi WChrifield,

Thank you for the only reply I have had to my question.  Is it possible to have a rule in an assembly to search for a named part and then return the Zoffset from the matrix when the rule is run rather than have to manually select the individual parts?

 

Thanks in advance,

Andrew

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor

When you say 'named part', do you mean the name of the component (like "Part1:1"), or the file name of the PartDocument that the component represents (like "Part1", or "Part1.ipt", or "C:\Temp\Part1.ipt")?  If you just mean find a component by its component name, then that is fairly easy using the ComponentOccurrences.ItemByName().  If you mean by the part's file name, then which version of the file name to you want to use to find it...full file name, file name without path but with extension, or file name without path and without extension.  Sometimes the ComponentOccurrence.Definition.Document will return the document object you want, and other times it may be better to use the ComponentOccurrence.ReferencedDocumentDescriptor.ReferencedDocument.  (Things like ModelStates, iParts, iAssemblies, etc, can complicate things.)

Here is an example using the ItemByName property mentioned above: (you may need to change the name)

Dim oADoc As AssemblyDocument = ThisDoc.Document
oOccs = oADoc.ComponentDefinition.Occurrences
oOccName = "Part1:1"
oOcc = oOccs.ItemByName(oOccName)
oZOffset = oOcc.Transformation.Cell(3, 4)
MsgBox("The 'Z Offset' of the component named " & oOccName & " is:  " & oZOffset,,"")

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 5

andy.bostock
Explorer
Explorer
Hi, thank you very much, this is exactly what I was after.
Cheers,
Andrew
0 Likes