VBA Code to Select/Filter Vertical and Horizontal Lines

VBA Code to Select/Filter Vertical and Horizontal Lines

Anonymous
Not applicable
2,786 Views
5 Replies
Message 1 of 6

VBA Code to Select/Filter Vertical and Horizontal Lines

Anonymous
Not applicable

Hi,

 

I would like to know if it is possible to select all vertical lines and make them a particular colour, and to then select all horizontal lines and make them a certain colour using VBA? I feel like i need to use delta x and y or the angles e.g 90, 180, 270.

 

Would anyone be able to assist me?

 

0 Likes
2,787 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Is there any sample .dwg file ??

0 Likes
Message 3 of 6

Ed__Jobe
Mentor
Mentor

First you would create a selection set, filtering for all lines.

Then in a Select..Case structure, examine the AcadLine.Angle property

I would then set the line's Layer property and leave the color as ByLayer. That way you can use LAYISO.

Remember, acad lisp and vba express angles in radians.

You should find code samples in this forum for all of the steps above.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 4 of 6

Anonymous
Not applicable

Here is an example of my drawing. I know how to do it manually by using the qselect command but no other way

0 Likes
Message 5 of 6

Anonymous
Not applicable

Dim obj As AcadObject Dim line_obj As AcadLine For Each obj In Thisdrawing.Modelspace If TypeOf obj Is AcadLine Then Set line_obj = obj If line_obj.angle = 0 Then line_obj.color = acRed If Int(line_obj.angle / pi) = 180 Then line_obj.color = acRed line_obj.Update End If Next obj

Message 6 of 6

HoshangMustafa
Advisor
Advisor

You wrote:

I know how to do it manually by using the qselect command

How can you do it manually by using quick select command?

0 Likes