dimension text back to center.

dimension text back to center.

belash007
Contributor Contributor
560 Views
2 Replies
Message 1 of 3

dimension text back to center.

belash007
Contributor
Contributor
i am using below code to get dimension text back to center. But my problem is that i just want to do text in center only selected Dimesions ..NOT ALL Dimesion in sheet. Below code re-set all the dimesions. Could any body help me in this regard. Thanks, Belash Sub DimensionArrange() ' Set a reference to the active drawing document Dim oDoc As DrawingDocument Set oDoc = ThisApplication.ActiveDocument ' Set a reference to the active sheet Dim oSheet As Sheet Set oSheet = oDoc.ActiveSheet Dim oDrawingDim As DrawingDimension ' Iterate over all dimensions in the drawing and ' center them if they are linear or angular. For Each oDrawingDim In oSheet.DrawingDimensions If TypeOf oDrawingDim Is LinearGeneralDimension Or _ TypeOf oDrawingDim Is AngularGeneralDimension Then Call oDrawingDim.CenterText End If Next End Sub
0 Likes
Accepted solutions (1)
561 Views
2 Replies
Replies (2)
Message 2 of 3

frederic.vandenplas
Collaborator
Collaborator

You need to add the selected dimensions to a selection set, and then loop through the selection set

 

This should help you:

http://forums.autodesk.com/t5/inventor-general-discussion/re-select-selected-items-after-changing-di...

 

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 3 of 3

belash007
Contributor
Contributor
Accepted solution
Thank you so much !! i have modified Code as below and it is working. Thanks alot! Sub DimTest() Dim doc As DrawingDocument Set doc = ThisApplication.ActiveDocument Dim collec As ObjectCollection Set collec = ThisApplication.TransientObjects.CreateObjectCollection Dim obj As Variant For Each obj In doc.SelectSet collec.Add obj Next For Each obj In collec If TypeOf obj Is LinearGeneralDimension Or _ TypeOf obj Is AngularGeneralDimension Then Call obj.CenterText 'Dim drawDim As DrawingDimension 'Set drawDim = obj 'drawDim.HideValue = True 'drawDim.OverrideModelValue = True 'drawDim.Text.HorizontalJustification = kAlignTextCenter End If Next For Each obj In collec doc.SelectSet.Select obj Next End Sub
0 Likes