Some customer might want to switch units between in and mm quickly. This could enable to make some measurements in mm and the quickly switch back to in.
For example if Ilogic Browser is displayed and you have to make these units changes very often, you can do it quite quickly writing this rule :
Pour les personnes qui doivent regulierement passer de in a mm comme unite dans les documents Inventor, vous pouvez le faire avec la regle Ilogic ci dessous :
doc=ThisDoc.Document
units=doc.unitsofmeasure.lengthunits
Ifunits=11269Then
doc.unitsofmeasure.lengthunits=11272
EndIf
Ifunits=11272Then
doc.unitsofmeasure.lengthunits=11269
EndIf
11269 and 11272 are values valid for in and mm.
Hello, I would like to do the same thing but using a macro so that I can assign it to a keyboard shortcut. I can get the units to change but the update command I'm using exits out of the sketch. I would like to be able to run this in the sketch, part, or assembly and have it automatically update the units the same way as if you manually changed them. Any help is appreciated. Thanks.
Currently my script is
Public Sub units()
Dim oPartDoc As Inventor.PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
' Set a reference to the UnitsOfMeasure object of the
' active document. Dim oUOM As UnitsOfMeasure
Set oUOM = ThisApplication.ActiveDocument.UnitsOfMeasure
' Display information about the current unit settings.
' Get the current length units.
Dim eLengthUnits As UnitsTypeEnum
eLengthUnits = oUOM.LengthUnits
' Checks to see if units are in mm
If oUOM.LengthUnits = kMillimeterLengthUnits Then
' If true then switches to inches
oUOM.LengthUnits = kInchLengthUnits
oUOM.LengthDisplayPrecision = 3
' If false then switches to mm
Else
oUOM.LengthUnits = kMillimeterLengthUnits
oUOM.LengthDisplayPrecision = 2
End If
oPartDoc.Update
End Sub
So I was trying to do the update with :
Dim oPartDoc As Inventor.PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
oPartDoc.Update
But I think I just need a different update command which updates the active window. If I take that code out, run my script, then modify anything on the sketch, the units update. I just dont know what command to use to make the screen update.
Hello Iman
I don't think you can get that kind of update properly in sketch environment. You need to exit and update.
I'd use this trick, if Sketch active, then exit sketch update and come back in. Code is a bit slower but it seems to work
Dim Osketch As Sketch
If oPartDoc.SketchActive = True Then
Set Osketch = ThisApplication.ActiveEditObject
Osketch.ExitEdit
oPartDoc.Update
Osketch.Edit
Else: oPartDoc.Update
End If
Hope this helps.