Inventor Drawing 2020 - ilogic error (setting dimension styles)

Inventor Drawing 2020 - ilogic error (setting dimension styles)

Anonymous
Not applicable
786 Views
5 Replies
Message 1 of 6

Inventor Drawing 2020 - ilogic error (setting dimension styles)

Anonymous
Not applicable

Hi all, 

 

After some help/feedback on below coding issue i have been having. Seems to have only become an issue since upgrading to Inventor 2020 (worked fine in previous versions). 

 

Intention of code is to select a drawing style from set selection and applying that to all sheets. (changing decimal places of dimensions is only real parameter being changed at moment). 

 

I have a code which works to change all of the "visible" dimensions. This one is to change the style itself for all future dimensions. 

 

My coding knowledge is fairly minimal, have pieced this code together from various forums.

 

Error seems to begin at highlighted line below:

 

 

Thanks in advance for any help!

breidTQXDW_1-1595378427536.png

 

 

breidTQXDW_0-1595378400908.png

 

0 Likes
Accepted solutions (1)
787 Views
5 Replies
Replies (5)
Message 2 of 6

marcin_otręba
Advisor
Advisor
Accepted solution

try:

Dim drw As DrawingDocument = ThisDoc.Document
drw.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.LinearDimensionStyle= drw.StylesManager.Styles.Item("Default - Method 2a (ISO)")

 

drw.StylesManager.ActiveStandardStyle.ActiveObjectDefaults - will change whole style not dimmension style

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 3 of 6

WCrihfield
Mentor
Mentor

Try this:

 

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oStMgr As DrawingStylesManager = oDDoc.StylesManager
Dim oDimStyles As DimensionStylesEnumerator = oStMgr.DimensionStyles
Dim oADefs As ObjectDefaultsStyle = oStMgr.ActiveStandardStyle.ActiveObjectDefaults
Dim oDStyle As DimensionStyle
If Prec_Set = "Dim Prec 0" Then
	oDStyle = oDimStyles.Item("Dim Prec 0")
	oADefs.AngularDimensionStyle = oDStyle
	oADefs.BaselineDimensionLayer = oDStyle
	oADefs.ChainDimensionStyle = oDStyle
	oADefs.DiameterDimensionStyle = oDStyle
	oADefs.LinearDimensionStyle = oDStyle
	oADefs.OrdinateDimensionStyle = oDStyle
	oADefs.OrdinateSetDimensionStyle = oDStyle
	oADefs.RadialDimensionStyle = oDStyle
ElseIf Prec_Set = "Dim Prec 1" Then
	oDStyle = oDimStyles.Item("Dim Prec 1")
	oADefs.AngularDimensionStyle = oDStyle
	oADefs.BaselineDimensionLayer = oDStyle
	oADefs.ChainDimensionStyle = oDStyle
	oADefs.DiameterDimensionStyle = oDStyle
	oADefs.LinearDimensionStyle = oDStyle
	oADefs.OrdinateDimensionStyle = oDStyle
	oADefs.OrdinateSetDimensionStyle = oDStyle
	oADefs.RadialDimensionStyle = oDStyle
ElseIf Prec_Set = "Dim Prec 2" Then
	oDStyle = oDimStyles.Item("Dim Prec 2")
	oADefs.AngularDimensionStyle = oDStyle
	oADefs.BaselineDimensionLayer = oDStyle
	oADefs.ChainDimensionStyle = oDStyle
	oADefs.DiameterDimensionStyle = oDStyle
	oADefs.LinearDimensionStyle = oDStyle
	oADefs.OrdinateDimensionStyle = oDStyle
	oADefs.OrdinateSetDimensionStyle = oDStyle
	oADefs.RadialDimensionStyle = oDStyle
ElseIf Prec_Set = "Dim Prec 3" Then
	oDStyle = oDimStyles.Item("Dim Prec 3")
	oADefs.AngularDimensionStyle = oDStyle
	oADefs.BaselineDimensionLayer = oDStyle
	oADefs.ChainDimensionStyle = oDStyle
	oADefs.DiameterDimensionStyle = oDStyle
	oADefs.LinearDimensionStyle = oDStyle
	oADefs.OrdinateDimensionStyle = oDStyle
	oADefs.OrdinateSetDimensionStyle = oDStyle
	oADefs.RadialDimensionStyle = oDStyle
ElseIf Prec_Set = "Dim Prec 4" Then
	oDStyle = oDimStyles.Item("Dim Prec 4")
	oADefs.AngularDimensionStyle = oDStyle
	oADefs.BaselineDimensionLayer = oDStyle
	oADefs.ChainDimensionStyle = oDStyle
	oADefs.DiameterDimensionStyle = oDStyle
	oADefs.LinearDimensionStyle = oDStyle
	oADefs.OrdinateDimensionStyle = oDStyle
	oADefs.OrdinateSetDimensionStyle = oDStyle
	oADefs.RadialDimensionStyle = oDStyle
End If

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE" 👍.

Also, when you have time, please review & vote for these 'Ideas' I'd like to get implemented.

  • Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
  • Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
  • Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
  • Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
  • Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
  • SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
  • Create DocumentSubTypeEnum Click Here
  • Add kRevisionTag or kDrawingRevisionTag to ObjectTypeEnum Click Here

Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 6

Anonymous
Not applicable

Thanks for feedback.

However neither of these 2-options appears to work.

 

Below is error when code supplied by WCrihfield is run.

 

breidTQXDW_1-1595555934503.png

 

 

0 Likes
Message 5 of 6

Anonymous
Not applicable

Hi @marcin_otręba ,

 

ended up using your code and tweeking slightly to get this to work for me. Thankyou. 

Probably not as neat as could be written, but does the job for now.

 

Thanks for help.

Code attached for reference. 

0 Likes
Message 6 of 6

WCrihfield
Mentor
Mentor

I see the error in my code now. I was using the value of the parameter instead of the name of the actual style.

Here's the corrected and condensed version, if you want it.

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oStMgr As DrawingStylesManager = oDDoc.StylesManager
Dim oDimStyles As DimensionStylesEnumerator = oStMgr.DimensionStyles
Dim oADefs As ObjectDefaultsStyle = oStMgr.ActiveStandardStyle.ActiveObjectDefaults
Dim oDStyle As DimensionStyle
If Prec_Set = "Dim Prec 0" Then
	oDStyle = oDimStyles.Item("Style_ODP")
ElseIf Prec_Set = "Dim Prec 1" Then
	oDStyle = oDimStyles.Item("Style_1DP")
ElseIf Prec_Set = "Dim Prec 2" Then
	oDStyle = oDimStyles.Item("Style_2DP")
ElseIf Prec_Set = "Dim Prec 3" Then
	oDStyle = oDimStyles.Item("Style_3DP")
ElseIf Prec_Set = "Dim Prec 4" Then
	oDStyle = oDimStyles.Item("Style_4DP")
End If
oADefs.AngularDimensionStyle = oDStyle
oADefs.BaselineDimensionLayer = oDStyle
oADefs.ChainDimensionStyle = oDStyle
oADefs.DiameterDimensionStyle = oDStyle
oADefs.LinearDimensionStyle = oDStyle
oADefs.OrdinateDimensionStyle = oDStyle
oADefs.OrdinateSetDimensionStyle = oDStyle
oADefs.RadialDimensionStyle = oDStyle

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes