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
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
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.
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.
Thanks for the link _dscholtes_!!
Thanks for the link _dscholtes_!!
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.
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
(Not an Autodesk Employee)
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.
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
(Not an Autodesk Employee)
Thanks for the additional info @WCrihfield !! I'll definately check those out.
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.