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: 

iLogic changes UOM shown on drawings

4 REPLIES 4
Reply
Message 1 of 5
mark.haustein
367 Views, 4 Replies

iLogic changes UOM shown on drawings

mark.haustein
Explorer
Explorer

I just started using iLogic and am looking for some verification that I'm doing things correctly. We mainly use lbmass on our drawings for the UOM we enter into our ERP system, but some parts use length (usually in ft).  I've updated our drawing template to look for a parameter from the model (named Length).  If Length exists, it uses that to insert into the UOM field on our drawings.  If it's not there, then it pulls in the mass from the model.  It looks like it works, but I'm a little hesitant to publish these templates since I'm so new to iLogic.  Does my code look correct?  Am I missing something that could cause issues?

 

I'm curious if there is a better way to deal with the mass property.  Before this code I had the mass from the model automatically fill in the value on our title block and it always pulled in lbmass.  With this code, it changed the units to kg and I had to convert it.  Is there a way to fill in this value without having to convert?

 

Is there a way to detect the units tied to the parameters (length)?  We usually draw things in inches, but we do have some parts that are in mm.  I'd like to add something to the code to know what do do when parts are in mm instead of inches. 

 

Here's my code:

 

'get the model the drawing is referencing (1st view)
modelname = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)

Parameter.Quiet = True

If Parameter(modelname, "Length") Then
	UOM = Parameter(modelname, "Length")
	iProperties.Value("Custom", "UOM") = UOM / 12
	iProperties.Value("Custom", "Units") = "ft"
Else
	UOM = iProperties.Mass(modelname)
	iProperties.Value("Custom", "UOM") = UOM * 2.20462
	iProperties.Value("Custom", "Units") = "lbmass"

End If

'update drawing
iLogicVb.UpdateWhenDone = True

 

0 Likes

iLogic changes UOM shown on drawings

I just started using iLogic and am looking for some verification that I'm doing things correctly. We mainly use lbmass on our drawings for the UOM we enter into our ERP system, but some parts use length (usually in ft).  I've updated our drawing template to look for a parameter from the model (named Length).  If Length exists, it uses that to insert into the UOM field on our drawings.  If it's not there, then it pulls in the mass from the model.  It looks like it works, but I'm a little hesitant to publish these templates since I'm so new to iLogic.  Does my code look correct?  Am I missing something that could cause issues?

 

I'm curious if there is a better way to deal with the mass property.  Before this code I had the mass from the model automatically fill in the value on our title block and it always pulled in lbmass.  With this code, it changed the units to kg and I had to convert it.  Is there a way to fill in this value without having to convert?

 

Is there a way to detect the units tied to the parameters (length)?  We usually draw things in inches, but we do have some parts that are in mm.  I'd like to add something to the code to know what do do when parts are in mm instead of inches. 

 

Here's my code:

 

'get the model the drawing is referencing (1st view)
modelname = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)

Parameter.Quiet = True

If Parameter(modelname, "Length") Then
	UOM = Parameter(modelname, "Length")
	iProperties.Value("Custom", "UOM") = UOM / 12
	iProperties.Value("Custom", "Units") = "ft"
Else
	UOM = iProperties.Mass(modelname)
	iProperties.Value("Custom", "UOM") = UOM * 2.20462
	iProperties.Value("Custom", "Units") = "lbmass"

End If

'update drawing
iLogicVb.UpdateWhenDone = True

 

Labels (1)
4 REPLIES 4
Message 2 of 5
_dscholtes_
in reply to: mark.haustein

_dscholtes_
Advocate
Advocate

Must read: DE101-1 Inventor® API- Exploring iProperties and Parameters (22 pages including code examples).
It's an Autodesk University document, written by one of the 'founders' of the Inventor API: Brian Ekins.



0 Likes

Must read: DE101-1 Inventor® API- Exploring iProperties and Parameters (22 pages including code examples).
It's an Autodesk University document, written by one of the 'founders' of the Inventor API: Brian Ekins.



Message 3 of 5

mark.haustein
Explorer
Explorer

Thanks for the link _dscholtes_!! 

0 Likes

Thanks for the link _dscholtes_!! 

Message 4 of 5
WCrihfield
in reply to: mark.haustein

WCrihfield
Mentor
Mentor

Here are more handy / quick links to online help pages that mention the 'database units'.  The database units are the ones Inventor uses internally, no matter what document units are set to.  Often when doing things involving math and measurements in iLogic, the results are in these 'database units', instead of document units.

Unit of Measure 

UnitsTypeEnum Enumerator  (within this listing, you will see multiple types of 'database units' mentioned

They have been a constant annoyance to most Inventor users who work heavily with iLogic, and prefer to use other units, for many years.  It would be great if we had the power to change it, just for our specific installation of Inventor, but we don't.  All we can do is set 'standards' and set document units in our templates.

 

There is a specific set of tools in iLogic that will allow you to create mathematical (transient geometry) objects that can be created using document units instead of database units, though.

ThisDoc.Geometry.Point2d()
ThisDoc.Geometry.Point2dList()
ThisDoc.Geometry.Point()
ThisDoc.Geometry.Vector2d()
ThisDoc.Geometry.Vector()
ThisDoc.Geometry.Matrix()

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 have time, please... Vote For My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes

Here are more handy / quick links to online help pages that mention the 'database units'.  The database units are the ones Inventor uses internally, no matter what document units are set to.  Often when doing things involving math and measurements in iLogic, the results are in these 'database units', instead of document units.

Unit of Measure 

UnitsTypeEnum Enumerator  (within this listing, you will see multiple types of 'database units' mentioned

They have been a constant annoyance to most Inventor users who work heavily with iLogic, and prefer to use other units, for many years.  It would be great if we had the power to change it, just for our specific installation of Inventor, but we don't.  All we can do is set 'standards' and set document units in our templates.

 

There is a specific set of tools in iLogic that will allow you to create mathematical (transient geometry) objects that can be created using document units instead of database units, though.

ThisDoc.Geometry.Point2d()
ThisDoc.Geometry.Point2dList()
ThisDoc.Geometry.Point()
ThisDoc.Geometry.Vector2d()
ThisDoc.Geometry.Vector()
ThisDoc.Geometry.Matrix()

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 have time, please... Vote For My IDEAS :light_bulb:or you can Explore My CONTRIBUTIONS

Inventor 2021 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 5

mark.haustein
Explorer
Explorer

Thanks for the additional info @WCrihfield !!  I'll definately check those out. 

0 Likes

Thanks for the additional info @WCrihfield !!  I'll definately check those out. 

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

Post to forums  

Autodesk Design & Make Report