VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need assistance with filtering and modifying dimension properties

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
gregatkinson8974
340 Views, 3 Replies

Need assistance with filtering and modifying dimension properties

I am fairly new to VBA customization of AutoCAD and need some assistance.

 

I am trying to modify the .LinearScaleFactor of different types of dimensions in a drawing using VBA.

 

I am having an issue with properly filtering for the types of dimensions that require this change.

 

I have narrowed it down to needing to filter the selection set for the list of different types of dimensions below but am unsure of how to approach it.

 

AcadDimAligned

AcadDimArcLength

AcadDimDiametric

AcadDimOrdinate

AcadDimRadial

AcadDimRadialLarge

AcadDimRotated

 

I have tried using the filter (0 . "Dimension") but this selection set does not allow me to change the .LinearScaleFactor I am assuming because there are some dimension types which do not have this property.

 

There is likely a simple way of doing this but I am not seeing it.

 

If you need any further information, please let me know.  Thanks.

 

3 REPLIES 3
Message 2 of 4
RICVBA
in reply to: gregatkinson8974

after creating and populating your selectionset you could iterate through it like follows (where i assumed "SSet1" as the name of your AcadSelectionSet object)

    Dim element As AcadEntity
    For Each element In SSet1
    
        If (TypeOf element Is AcadDimAligned _
            Or TypeOf element Is AcadDimAngular _
            Or TypeOf element Is AcadDimArcLength _
            Or TypeOf element Is AcadDimDiametric _
            Or TypeOf element Is AcadDimOrdinate _
            Or TypeOf element Is AcadDimRadial _
            Or TypeOf element Is AcadDimRadialLarge _
            Or TypeOf element Is AcadDimRotated) _
            Then element.LinearScaleFactor = 10#
            
    Next element

 

or, in a more roughly (and somehow more elegant as well!) way 

    Dim element As AcadEntity
    On Error Resume Next
    For Each element In SSet1
        element.LinearScaleFactor = 10#
    Next element
    On Error GoTo 0

the first way you can also have more control over a specific dimension type, adding code to handle different linear scalefactors for each different dimension type

the second way you don't bother of what dimension type you might have collected in your selectionset and simply switch off normal error handling just passing it by thus executing the linearscale instruction only on objects supporting this property

 

hope this is what you need

bye

 

 

Message 3 of 4
gregatkinson8974
in reply to: RICVBA

Yes, that is exactly what I needed.  Thanks for your help.

Message 4 of 4
RICVBA
in reply to: gregatkinson8974

you're welcome

 

you could then mark the topic as solved

 

bye

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost