Hi Mike,
Handent is Vanilla AutoLisp function this will allow you to get
object by its handle (this one is stored in dxf code 5 in entity list),
see edited code:
Code:
Option Explicit
Sub UpdateExistingDimensionStyles()
'On Error GoTo Err_Control
Dim MySelectionSet As AcadSelectionSet
Dim MyCollectionSet As AcadSelectionSets
Dim MyCollectionSetName As String
MyCollectionSetName = "TheDimensionsToUpdate"
Dim MyObject As AcadEntity
Dim MyDimension As AcadDimension
Dim dxfcode(0) As Integer
Dim dxfValue(0) As Variant
'-----------------------------------------------------------------------------------
With ThisDrawing
Set MyCollectionSet = ThisDrawing.SelectionSets
For Each MySelectionSet In MyCollectionSet
If MySelectionSet.Name = MyCollectionSetName Then
.SelectionSets.Item(MyCollectionSetName).Delete
Exit For
End If
Next
Set MySelectionSet = .SelectionSets.Add(MyCollectionSetName)
End With
'-----------------------------------------------------------------------------------
dxfcode(0) = 0
dxfValue(0) = "DIMENSION"
Dim groupCode As Variant
Dim dataCode As Variant
groupCode = dxfcode
dataCode = dxfValue
Dim mode As Integer
mode = acSelectionSetAll '<-- declared explicitly
''you can see the syntax of this method in the Help file:
MySelectionSet.Select mode, , , groupCode, dataCode '<-- omitted the window selection points(as commas)
For Each MyObject In MySelectionSet
Set MyDimension = MyObject
If TypeOf MyDimension Is AcadDimension Then
Dim MyHandle As String
MyHandle = MyDimension.Handle
'removed extrafluous VbCr from the next line:
ThisDrawing.SendCommand "dim" & vbCr & "HOME" & vbCr & "L" & vbCr & "(handent " & Chr(34) & MyHandle & Chr(34) & ")" & vbCr & vbCr
ThisDrawing.SendCommand Chr(27) & Chr(27) & Chr(27)
MyObject.Update
End If
Next
'Optional for this code context, because of you deleted this selection set on the start of code:
'MySelectionSet.Clear
'MySelectionSet.Delete
'-----------------------------------------------------------------------------------
'Set MySelectionSet = Nothing
'Set MyDimension = Nothing
ThisDrawing.PurgeAll
ThisDrawing.PurgeAll
ThisDrawing.PurgeAll
Application.ZoomExtents
'ThisDrawing.Save
'Err_Control:
'MsgBox Err.Number
MsgBox (" POKEY")
End Sub
~'J'~
Bookmarks