I need to modify the placement of a dimension based on certain criteria. This would be just moving the text part of the dimension.
Modify, Element (7,1) will allow you to grab just the text from the dimension and move it. It also allows you to move the dimension line if you click on it rather than the text. I'm not clear if you are trying to move the text after it was put in by VBA or trying to use VBA to move it. I've not tried moving the text of a dimension via VBA but I believe it would be straightforward. The difficult part would be the "based on certain criteria". I'm guessing that means something like not overlapping other elements which is possible but would take a lot more code and thought to get working. If you clarify what you are trying to accomplish we might have more suggestions.
Larry WilsonLWilson@LJBinc.com
Hi Larry,
Would you mind reviewing the code in this first topic "VBA - V8i) Set Dimension Offset" from the search I performed: vba AND dimension AND text AND (move OR offset); and see if it helps? If not, would you mind attaching a simplified standalone version of a .mvba project for others to possibly help contribute to directly?
Thank you and HTH,Bob
Unknown said: I did do a search and did find that page. The problem I ran into was that all the links on that page produces a oops page, page had been moved or is no longer available.
I did do a search and did find that page. The problem I ran into was that all the links on that page produces a oops page, page had been moved or is no longer available.
Those have been fixed... apologies for the inconvenience (and thanks for pointing that out).
Below is some sample code showing how to offset dimension text. Select one or more dimension elements and run TEST_DimTextOffset. Note: you may need to apply additional rotations if needed.
Sub TEST_DimTextOffset() DimTextOffset 0.5, True End Sub Sub DimTextOffset(dOffsetX As Double, bInside As Boolean) Dim eE As ElementEnumerator Dim eE2 As ElementEnumerator Dim p1 As Point3d Dim p2 As Point3d Dim dimEle As DimensionElement Dim dimStyle As DimensionStyle ' Exit if no elements selected: Set eE = ActiveModelReference.GetSelectedElements If Not eE.MoveNext Then MsgBox "No elements selected" Exit Sub End If eE.Reset 'process all dimension elements: 'Dim sC As New ElementScanCriteria 'sC.ExcludeAllTypes 'sC.IncludeType msdElementTypeDimension 'Set eE = ActiveModelReference.GraphicalElementCache.Scan(sc) 'process selected elements: Do While eE.MoveNext Set dimEle = eE.Current Set dimStyle = dimEle.DimensionStyle 'terminator is in or out: If bInside Then dimStyle.TerminatorMode = msdDimTerminatorModeInside Else dimStyle.TerminatorMode = msdDimTerminatorModeOutside End If dimEle.DimensionStyle = dimStyle dimEle.Rewrite 'search text in dimension: Set eE2 = dimEle.Drop Do While eE2.MoveNext If eE2.Current.Type = msdElementTypeText Then p1 = eE2.Current.AsTextElement.Origin p2 = p1 p2.X = p2.X + dOffsetX End If Loop 'offset dimension text: CadInputQueue.SendKeyin "modify dimension loc" CadInputQueue.SendDragPoints p1, p2 CommandState.StartDefaultCommand Loop End Sub
Best regards,Artur
Could you provide some criteria to define to us your definition of what the last dimension placed entails? Is your code placing the dimension, a user operation in MicroStation using MicroStation tools, last dimension updated as an auto dimension update? What information do you need about the last dimension, and what will happen next to that last dimension? Is there only one that will be affected? Also, please consider marking a prior response with "Verify Answer" if the primary issue was resolved by one or more responses. Second, especially if the primary issue has been resolved consider creating a new post/thread for quicker responses. This way others will clearly see when new question(s) are being asked and not have search/read through a potentially lengthy thread to find an unanswered question remains. HTH, Bob