Add Dimension user parameter for GAUGE

Add Dimension user parameter for GAUGE

Anonymous
Not applicable
1,004 Views
7 Replies
Message 1 of 8

Add Dimension user parameter for GAUGE

Anonymous
Not applicable

I can edit a dimension on an inventor dwg manually by "Edit Dimension", then "Format Text", then select "user parameter", then select "GAUGE" from the list.  The question is: can this done automatically with ilogic or VB.NET ?

 

I want to display a GAUGE dimension as "10 GA (0.135)" instead of just "0.135"

 

The GAUGE parameter brings in the 10.  I add the GA text manually.

 

Thanks,

 

JCKCAD

0 Likes
Accepted solutions (3)
1,005 Views
7 Replies
Replies (7)
Message 2 of 8

dgreatice
Collaborator
Collaborator

hi, can you provide screenshot?

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes
Message 3 of 8

Anonymous
Not applicable

Attached is a PDF screen shot.

 

I found this code online for an iLogic routine.  The line for formatting the text has "<DimensionValue/>", which is a code to maintain the dimension value.  This helps a lot.  Now I just need the "<???/>" code for GAUGE.  I see in this code that "<br/>" does a return to next line.  So, I'm assuming that GAUGE has a similar code.

 

'get model document (part or assembly) from the parent DrawingDocument
modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName)
'save text parameter "MyText" value in the string variable Value
Dim Value As String = Parameter(modelName, "MyText")
'Note: this string Value could be read from any source (e.g., excel sheet).
Dim oDoc As DrawingDocument = ThisDrawing.Document
Dim oSSet As SelectSet = oDoc.SelectSet
If oSSet.Count = 0 Then
MessageBox.Show("Select at least one dimension please", "DIM", _
MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
For Each obj As Object In oSSet
'filter dimensions, ignore other selected entities
If TypeOf obj Is GeneralDimension Then
'reference to the selected dimension
Dim oDim As GeneralDimension = obj
'refrence to the DimensionText object
Dim oDimensionText As DimensionText = oDim.Text
'change dimension text
oDimensionText.FormattedText = "<DimensionValue/>" & "<br/>" & Value
End If
Next
End If
Beep

0 Likes
Message 4 of 8

MechMachineMan
Advisor
Advisor
Accepted solution

1. Please use the code block as it increases readability.

2. Use code to see what the formatted text is BEFORE you put in gauge, and then AFTER. The difference is the stuff relevant to adding gauge. Mimic this for the cases you want to add gauge.

 

Dim oDoc As DrawingDocument = ThisDrawing.Document
Dim oSSet As SelectSet = oDoc.SelectSet
If oSSet.Count <> 1 Then
    MsgBox("Select only one dimension!")
Else
obj = oSSet.Item(1) If TypeOf obj Is GeneralDimension Then Dim oDim As GeneralDimension = obj Dim oDimensionText As DimensionText = oDim.Text MsgBox(oDimensionText.FormattedText)
'oDimensionText.FormattedText = oDimensionText.FormattedText & "new stuff here"
End If
End If
Beep

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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 5 of 8

Anonymous
Not applicable
Accepted solution

I figured it out by having the program display the formatted text on an existing dimension, which gave me the format to use.  Here is the code.

 

Sub Gauge_Dim_Style()

  Dim oDoc As DrawingDocument
  Set oDoc = ThisApplication.ActiveDocument
  Dim oSSet As SelectSet
  Set oSSet = oDoc.SelectSet
  
  'reference to the selected view
  Dim oView As DrawingView
  Set oView = oSSet.Item(1)
  
  'get the part name from the view
  Dim oPartName As String
  oPartName = oView.ReferencedDocumentDescriptor.FullDocumentName
  
  'reference to the selected dimension
  Dim oDim As LinearGeneralDimension
  Set oDim = oSSet.Item(2)
  
  'refrence to the DimensionText object
  Dim oDimensionText As DimensionText
  Set oDimensionText = oDim.Text

  'reference to the style manager
  Dim oStylesMgr As DrawingStylesManager
  Set oStylesMgr = oDoc.StylesManager
  
  'get the reference to the target dimension style (by name)
  Dim oNewStyle As DimensionStyle
  Set oNewStyle = oStylesMgr.DimensionStyles.Item("Decimal - 3 Place")
  oDim.Style = oNewStyle
  
  'change text
  oDimensionText.FormattedText = "<Parameter Resolved='True' ComponentIdentifier='" & oPartName & "' Name='GAUGE' Precision='0'>1</Parameter>" & " GA (<DimensionValue/>)"
  Beep

End Sub
0 Likes
Message 6 of 8

MechMachineMan
Advisor
Advisor
Accepted solution

So this is solved now then?


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

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 7 of 8

Anonymous
Not applicable
Yes
0 Likes
Message 8 of 8

dgreatice
Collaborator
Collaborator
Hi. Why must go inside to dimension style?

Because it become <style overide>?
Why not just deleted this xml "style overide"?
Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes