Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Measurements values add to Iproperties

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
alexander.naljot
707 Views, 9 Replies

Measurements values add to Iproperties

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. 

Bild 1.PNG

 

 

9 REPLIES 9
Message 2 of 10

Don't think so.

Message 3 of 10

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.

Message 4 of 10

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

EESignature

(Not an Autodesk Employee)

Message 5 of 10

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.

Message 6 of 10

Yes that's true with SWX, but in Revit it is possible with a specific plugin that you have install additional
"Bridge + Infrastructure Modeler". Revit is not in the same Ligue as Inventor but in the Tunneling you have to play in different leagues.
In this Video you can see it (https://vimeo.com/474110725)
Message 7 of 10

Thank you for your advice WCrihfield, yes you are absolutely right, I want to get this highlighted Area in Iproperties. I will test this tomorrow how I can solve this with ILogic. I think for quick understanding which result I need, you can watch this at example video how is it working in Revit. It is a specific plugin that you have to install for Revit (Bridge + Infrastructure Modeler). The same result I need also in Inventor.

https://vimeo.com/474110725
Message 8 of 10

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? 

alexandernaljot_0-1666779948573.png

 

Message 9 of 10

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

EESignature

(Not an Autodesk Employee)

Message 10 of 10

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report