iLogic to get all Dimension Style names

iLogic to get all Dimension Style names

engilic
Advocate Advocate
1,041 Views
6 Replies
Message 1 of 7

iLogic to get all Dimension Style names

engilic
Advocate
Advocate

Hi,

 

Please, how to mace iLogic code to gett all dimension style names that appear in the drop-down menu so later I can ask to choose one of them?

Screenshot 2021-04-29 082637.png

 

 

 

 

They also appear in Style and Standard Editor / Dimensions.

Screenshot 2021-04-29 083048.png

 

 

 

 

 

 

 

 

 

 

 

Thank you very much

 

Have a lovely day.

0 Likes
Accepted solutions (2)
1,042 Views
6 Replies
Replies (6)
Message 2 of 7

engilic
Advocate
Advocate

Just for Local Styles.

0 Likes
Message 3 of 7

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

Try this:

Dim oDrawDoc As DrawingDocument= ThisDoc.Document
Dim oStylesMgr As DrawingStylesManager = oDrawDoc.StylesManager

Dim oStyles As New List(Of String) 
Dim oStyle As Inventor.DimensionStyle
For Each oStyle In oStylesMgr.DimensionStyles
	oStyles.Add(oStyle.Name )    
Next

selection=InputListBox("Select  a style", oStyles)

MsgBox(selection) 									'<-- That's only the name
oStyle = oStylesMgr.DimensionStyles.Item(selection) '<-- That's the style object

R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 4 of 7

engilic
Advocate
Advocate

Thank you @Ralf_Krieg ,

 

Is it possible to control Filter Styles and get only Styles that are Local Styles or Active Standard?
Where is that information hiding for each Dimension Standard or any other standard?

Screenshot 2021-04-29 094805.png

0 Likes
Message 5 of 7

Ralf_Krieg
Advisor
Advisor
Accepted solution

Hello

 

The local styles option is possible through the stylelocation property. Maybe the styles which are also in the library (.kBothStyleLocation) are included in this filter. I've not found a simpel solution to get all dimension styles of the active standard.

Dim oDrawDoc As DrawingDocument= ThisApplication.ActiveDocument
Dim oStylesMgr As DrawingStylesManager = oDrawDoc.StylesManager

Dim oStyles As New List(Of String) 
Dim oStyle As Inventor.DimensionStyle
For Each oStyle In oStylesMgr.DimensionStyles
	If oStyle.StyleLocation=StyleLocationEnum.kLocalStyleLocation Then '.kBothStyleLocation, .kLibraryStyleLocation 
		oStyles.Add(oStyle.Name)
	End If
Next

selection=InputListBox("Select  a style", oStyles)

MsgBox(selection) 									'<-- That's only the name
oStyle = oStylesMgr.DimensionStyles.Item(selection) '<-- That's the style object

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 6 of 7

engilic
Advocate
Advocate

Thank you @Ralf_Krieg, will play a little bit with the code,

 

Would like to ask one more question instead of making a new post.

 

How to set Dimension Style to be By Standard and then it will be Style that is defined as standard?

 

I found that it is possible to do that for Dimension Layout by setting it to Nothing (.Layer = Nothing) but that doesn't work for Dimension Style.

0 Likes
Message 7 of 7

engilic
Advocate
Advocate

Thank you @Ralf_Krieg ,

 

This is awesome, just the .kLocalStyleLocation does not give back any style since those styles that are Local are set as kBothStyleLocation so I just used that, also, .InUse property can be used.

 

All Local Styles are kBothStyleLocation and InUse. Do not know what is the difference but for now, it seems there is not.

 

Please, please, how to make Dimension Style be By Standard?

 

.Style= Nothing doesn't work, like .Layer = Nothing does.

0 Likes