i logic to choose certain dimension style in drawing documents

i logic to choose certain dimension style in drawing documents

didin.suryadi6JREK
Advocate Advocate
451 Views
3 Replies
Message 1 of 4

i logic to choose certain dimension style in drawing documents

didin.suryadi6JREK
Advocate
Advocate

Hi,

 

Currently, when I open the old drawing I need to update the dim styles manually by right click and editing dimensions to the updated styles. Those are actually available in the "Style and Standard Editor".

Now I want to create a simple i-logic to show inputboxlist for me to choose the style. I have the drawing standard styles also to come up after that. I tried but found the error

Something like in the below capture, 

Dim oDoc As DrawingDocument = ThisDrawing.Document
Dim oDSMgr As New List(Of String)
Dim oStyle As DimensionStyle
For Each oStyle In oDoc.StylesManager.DimensionStyles
	oDSMgr.Add(oStyle.Name)
Next
oChoice = InputListBox("", oDSMgr, "", "Dimension Standard Styles", "Dimension Standard Styles List")
oStyle = oDoc.StylesManager.DimensionStyles.Item(oChoice)

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSStyles As New List(Of String)
For Each oSS As DrawingStandardStyle In oDDoc.StylesManager.StandardStyles
	oSStyles.Add(oSS.Name)
Next
oChoice = InputListBox("", oSStyles, "", "Drawing Standard Styles", "Drawing Standard Styles List")
If String.IsNullOrEmpty(oChoice) Then Exit Sub
Dim oStyle As DrawingStandardStyle = oDDoc.StylesManager.StandardStyles.Item(oChoice)
oDDoc.StylesManager.ActiveStandardStyle = oStyle

Can anyone give a clue?

 

Rgds

 

 

0 Likes
452 Views
3 Replies
Replies (3)
Message 2 of 4

dalton98
Collaborator
Collaborator

Changing the active style wont affect the old drawing, you will need cycle through every dimension in your drawing and change their style. Here is a good example:

https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/using-ilogic-to-change-dimension-sty...

 

And as far as automatically changing the active style it looks like you figured that out but this is how you would do that:

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
oDoc.StylesManager.ActiveStandardStyle = oDoc.StylesManager.StandardStyles.Item(2)
0 Likes
Message 3 of 4

didin.suryadi6JREK
Advocate
Advocate

Hi,

 

Thanks

 

I tried to fix the codes as per the below arrangement, The both box selections were come up but there is an error 

 

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oDSMgr As New List(Of String)
Dim oStyle As DimensionStyle
For Each oStyle In oDoc.StylesManager.DimensionStyles
	oDSMgr.Add(oStyle.Name)
Next
oChoice = InputListBox("", oDSMgr, "", "Dimension Standard Styles", "Dimension Standard Styles List")
oStyle = oDoc.StylesManager.DimensionStyles.Item(oChoice)

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSStyles As New List(Of String)
For Each oSS As DrawingStandardStyle In oDDoc.StylesManager.StandardStyles
	oSStyles.Add(oSS.Name)
Next
oChoice = InputListBox("", oSStyles, "", "Drawing Standard Styles", "Drawing Standard Styles List")
If String.IsNullOrEmpty(oChoice) Then Exit Sub
oDoc.StylesManager.ActiveStandardStyle = oDoc.StylesManager.StandardStyles.Item(2)
oDDoc.StylesManager.ActiveStandardStyle = oStyle

 Error Msg:

Error in rule: TEST AGAINN, in document: Test00A.002.idw

Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.DrawingStandardStyle'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{55DBDB4E-BC61-4D53-84F6-86CF24267DD8}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

0 Likes
Message 4 of 4

dalton98
Collaborator
Collaborator

You would use this to change standard style

oDoc.StylesManager.ActiveStandardStyle = oDoc.StylesManager.StandardStyles.Item(oChoice)

 Also, the standard style will change the drawing dimension style. If you want a different dimension style than the standard you should create a new standard style.

 

I'm assuming your goal is to change old drawings to match your new standard style. This is harder because you will need to go through each dimension and drawing line and change them. Also, changing the border and title block, but this is easier.

0 Likes