Hello dear Autodesk community, 😀
is there a way to add a value as an attribute from the measurement in Inventor to the Iproperties so that it is also associative. I would be very grateful for any help.
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Hello Pineapple,
I think in SWX it is possible, why not in Inventor. I have to repost this in API Forum maybe they have a solution.
Hi @alexander.naljot. I also do not think it could be 'truly' associative. I am assuming you are talking about the Area of the highlighted face in that image, because the value at the start of your arrow is in square meters, because the word beside it in the image is not in English. If you had a good way of identifying that specific face, so that it could be reliably found by code, such as maybe assigning a Name to it, then you could certainly get its Area and write that value to a custom iProperty. I assume you meant to say "iProperty", instead of "attribute", because attributes are different types of objects in Inventor's API. However, in order to keep the value accurate, you would have to set-up some sort of event triggering routine, so that every time one or more specific events happen, it will trigger an iLogic rule to run that will get the face's area again, and make sure the stored value is up to date. There is a fairly good event for that already set-up for us to take advantage of in part documents, within the Event Triggers dialog > This Document tab > and the event named "Part Geometry Change". If you put the iLogic rule under that event name in that dialog, it will cause the rule to run every time that part's geometry changes. Not exactly 'associative', but close.
Wesley Crihfield
(Not an Autodesk Employee)
I think you can copy the number in SWX. I believe you can do that in IV also.
I highly doubt SWX can do it. Since changing a sketch could break associated face and constrains.
I know now how it is working with a sketch I found this in this block.
https://inventorfaq.blogspot.com/2012/05/flache-einer-skizze-als-wert-in-den.html
But when you give a name to a surface, how can you get a Area from this with Ilogic?
Hi @alexander.naljot. Here is an example of an iLogic rule that you can use on a part document to find/get a named face, then get its area, then convert its units from default 'database' units (centimeters squared) to document units, then write that value to a custom iProperty. I just tested it in one of my parts, and it worked OK, but you may need to change the name I am specifying for the Face to match yours. I don't think my keyboard puts the two little dots over the letter "a", like what is shown in your image. Then, as I said before, try putting this rule under the "Part Geometry Change" event in the Event Triggers (and/or the "Any Model Parameter Change" event, if necessary).
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule to work. Exiting.", vbCritical, "")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oNEs As NamedEntities = iLogicVb.Automation.GetNamedEntities(oPDoc)
'<<<< CHANGE THIS NAME, IF IT DOES NOT MATCH YOUR FACE NAME >>>>
Dim sFaceName As String = "Stirnflache"
Dim oMyFace As Face = oNEs.TryGetEntity(sFaceName)
If IsNothing(oMyFace) Then
MsgBox("No Face named " & sFaceName & " was not found.", vbCritical, "Face Not Found")
Exit Sub
End If
Dim oArea As Double = oMyFace.Evaluator.Area
'convert units from 'database' units (centimeters squared) to document units
Dim UOM As UnitsOfMeasure = oPDoc.UnitsOfMeasure
If UOM.LengthUnits <> UnitsTypeEnum.kDatabaseLengthUnits Then
DLU = UOM.GetStringFromType(UOM.LengthUnits)
oArea = UOM.ConvertUnits(oArea, "cm^2", DLU & "^2")
End If
'now write this value to the custom iProperty
Dim oCProps As PropertySet = oPDoc.PropertySets.Item("Inventor User Defined Properties")
Dim oAreaProp As Inventor.Property = Nothing
Try
oAreaProp = oCProps.Item(sFaceName & " Area")
Catch
oAreaProp = oCProps.Add(oArea, sFaceName & " Area")
End Try
If oAreaProp.Value <> oArea Then oAreaProp.Value = oArea
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.