Macro/ add in to show override dimensions in sketch?

Macro/ add in to show override dimensions in sketch?

Anonymous
Not applicable
1,045 Views
9 Replies
Message 1 of 10

Macro/ add in to show override dimensions in sketch?

Anonymous
Not applicable

Hello, do you know a way to show which dimension is overrided after opening drawing? In our company we have some old drawing with overrides but we dont know which one and manual opening every dimension would be very.. irrational 😛 Any suggestions ?
Kind regards ^^

0 Likes
Accepted solutions (2)
1,046 Views
9 Replies
Replies (9)
Message 2 of 10

Jesper_S
Collaborator
Collaborator
Accepted solution

Hi.

 

Try this ilogic code.

 

'-------------Start Of ilogic ------------------------------------------------
' Set a reference to the active document.
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

'Define the drawing dims collection
Dim oDrawingDims As DrawingDimension

'Dim oColor As Inventor.Color
Dim oColor As Color

'Prompt user to choose highlight / un-highlight
Dim booleanParam as Object
booleanParam = InputRadioBox("Select an Option", _
"Hightlight Overrides", "Un-Hightlight Overrides", True, Title := "iLogic")

'Loop through all dimensions and set colors
For Each oDrawingDims In oDoc.ActiveSheet.DrawingDimensions
   If booleanParam = True Then
   'set color to magenta
   oColor = ThisApplication.TransientObjects.CreateColor(255, 0, 255)
   Else
   'set color to black
   oColor = ThisApplication.TransientObjects.CreateColor(0, 0, 0)
   oColor.ColorSourceType = ColorSourceTypeEnum.kLayerColorSource
   End If
  
   If oDrawingDims.HideValue = True _
   Or oDrawingDims.ModelValueOverridden = True Then
   oDrawingDims.Text.Color = oColor
   Else
   End If
Next
'-------------End of ilogic ------------------------------------------------

//Jesper


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Message 3 of 10

Anonymous
Not applicable

Many thanks! Works! 🙂 
Do you think that I could make that as a rule for every new or ever opened document ? 

0 Likes
Message 4 of 10

bradeneuropeArthur
Mentor
Mentor

Hi,

 

Yes this is possible:

 

Put then this code into the "After open" event trigger from I-logic.

 

' Set a reference to the active document.
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument

'Define the drawing dims collection
Dim oDrawingDims As DrawingDimension

Dim oColor As Color

'Loop through all dimensions and set colors
For Each oDrawingDims In oDoc.ActiveSheet.DrawingDimensions
 
   'set color to magenta
   oColor = ThisApplication.TransientObjects.CreateColor(255, 0, 255)

   If oDrawingDims.HideValue = True _
   Or oDrawingDims.ModelValueOverridden = True Then
   oDrawingDims.Text.Color = oColor
   Else
   End If
Next

 IlogicAfterOpen.PNG

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 5 of 10

Anonymous
Not applicable

Now I should pay off for this... for now I can give you only a Kudos and honest thanks 😛 Its hard to make macro from the first code ? 

0 Likes
Message 6 of 10

Jesper_S
Collaborator
Collaborator
Accepted solution

Hi.

 

Do you want it as a button on the ribbon?

 

Place the iLogic-code as a External rule. Save it as a .txt (notepad) document.

(I cant convert it to VBA)

 

 

Place this code in a Module in the VBA-editor.

Public Sub Dimensions()
RuniLogic ("Your iLogic code.txt") 'replace the red text with the name of your external rule
End Sub

Public Sub RuniLogic(ByVal RuleName As String)
Dim iLogicAuto As Object
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
If oDoc Is Nothing Then
MsgBox "Missing Inventor Document"
Exit Sub
End If
Set iLogicAuto = GetiLogicAddin(ThisApplication)
If (iLogicAuto Is Nothing) Then Exit Sub
iLogicAuto.RunExternalRule oDoc, RuleName
End Sub
Public Function GetiLogicAddin(oApplication As Inventor.Application) As Object
Dim addIn As ApplicationAddIn
On Error GoTo NotFound
Set addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")
If (addIn Is Nothing) Then Exit Function
addIn.Activate
Set GetiLogicAddin = addIn.Automation
Exit Function
NotFound:
End Function

You can now add the a button to the ribbon. Right-click on the ribbon and select "Customaize User Commands"

Ribbon.PNG

The macroname will be Dimensions

 

//Jesper


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Message 7 of 10

Anonymous
Not applicable

Thats everything what I needed, and even more beacuse you guided me very well so many thanks to you! I really appreciate you. 🙂 

0 Likes
Message 8 of 10

Jesper_S
Collaborator
Collaborator

If you got more external rules, you can easily add them to the ribbon also.

 

Just add more Public Subs.

 

Public Sub Button_Name()     
RuniLogic ("Rule Name.txt")
End Sub

Public Sub Dimensions()  'No special characters or spaces.
RuniLogic ("Your iLogic code.txt") 'replace the red text with the name of your external rule
End Sub

Public Sub Button_Name()   'No special characters or spaces.
RuniLogic ("Rule Name.txt") 
End Sub

Public Sub Button_Name()   'No special characters or spaces.
RuniLogic ("Rule Name.txt") 
End Sub

Public Sub RuniLogic(ByVal RuleName As String)
Dim iLogicAuto As Object
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
If oDoc Is Nothing Then
MsgBox "Missing Inventor Document"
Exit Sub
End If
Set iLogicAuto = GetiLogicAddin(ThisApplication)
If (iLogicAuto Is Nothing) Then Exit Sub
iLogicAuto.RunExternalRule oDoc, RuleName
End Sub
Public Function GetiLogicAddin(oApplication As Inventor.Application) As Object
Dim addIn As ApplicationAddIn
On Error GoTo NotFound
Set addIn = oApplication.ApplicationAddIns.ItemById("{3bdd8d79-2179-4b11-8a5a-257b1c0263ac}")
If (addIn Is Nothing) Then Exit Function
addIn.Activate
Set GetiLogicAddin = addIn.Automation
Exit Function
NotFound:
End Function

//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
Message 9 of 10

Anonymous
Not applicable

Thanks! Wonderful. Can I ask you where did you get these iLogic commands like "DrawingDims.ModelValueOverridden" or "DrawingDims.HideValue" ?

0 Likes
Message 10 of 10

Jesper_S
Collaborator
Collaborator

Hi.

 

Help.PNG

From there and from the Inventor Customization Forum.

 

//Jesper


//Jesper

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.