Selecting window and changing color

Selecting window and changing color

Anonymous
Not applicable
339 Views
5 Replies
Message 1 of 6

Selecting window and changing color

Anonymous
Not applicable
I'm having a hard time writing a simple program in VBA. I want the user to select a window in the drawing and in that window the program will filter only lines.

Now if a selected line is say magenta I want a program that will automatically turn the color into cyan.

Thanks in advance.
0 Likes
340 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Rough program outline.

Define filter for line entities that are magenta
Create selection set with filter
loop thro selection set
change colour property to cyan
delete selection set

Search this NG and the help files for specifics. Post back here if you get
stuck.

--
Regards
Tom Roberts
__________________________
MechWest Design & Drafting
Perth, Western Australia



wrote in message news:4930326@discussion.autodesk.com...
I'm having a hard time writing a simple program in VBA. I want the user to
select a window in the drawing and in that window the program will filter
only lines.

Now if a selected line is say magenta I want a program that will
automatically turn the color into cyan.

Thanks in advance.
0 Likes
Message 3 of 6

Anonymous
Not applicable
Having a hard time looping through selection set and I want to also include hatches.

Also, what's the line of code that asks for user to input a selection box (upper left corner to lower right corner)

Bernard
0 Likes
Message 4 of 6

Anonymous
Not applicable
Hello Bernard

To loop thro' a selection use something like the following:

Dim Ent As AcadEntity
Dim SS As AcadSelectionSet

For Each Ent In SS
'do something here...ie change colour
Ent.color = acCyan
Next Ent

To include hatches you need to add the OR operator to your selectionset
filter. You have got a filter working haven't you???
If not it looks something like this:

'set up filter data
gpCode(0) = -4: dataValue(0) = " gpCode(1) = -4: dataValue(1) = " gpCode(2) = 0: dataValue(2) = "LINE" 'filter for line
entities...
gpCode(3) = 0: dataValue(3) = "HATCH" 'or hatched entities...
gpCode(4) = -4: dataValue(4) = "OR>" 'close OR operator
gpCode(5) = 62: dataValue(5) = "6" 'that are colour magenta
(6)
gpCode(6) = -4: dataValue(6) = "AND>" 'close AND operator

Did you look up selection methods in the help file at all...
If you want to select via a window when your program will provide the window
coords use the SELECT method of the SelectionSet object.
If you want the User to enter the window use the SelectOnScreen method of
the SelectionSet object.
Both methods accept the filter as a parameter.

Keep at it. If you have any more problems post some code and will get it
nutted

--
Regards
Tom Roberts
__________________________
MechWest Design & Drafting
Perth, Western Australia




wrote in message news:4930933@discussion.autodesk.com...
Having a hard time looping through selection set and I want to also include
hatches.

Also, what's the line of code that asks for user to input a selection box
(upper left corner to lower right corner)

Bernard
0 Likes
Message 5 of 6

Anonymous
Not applicable
the filters can be simplified:
gpCode(0) = 0: dataValue(0) = "LINE,HATCH"
gpCode(1) = 62: dataValue(1) = 6

If you group like Objects into the same string, seperated by a comma it
implies OR
The SS function uses AND unless told otherwise. So the filters above will be
read by the SS function as "If an object is a Line OR Hatch, AND it is the
color 6, include it.

When filtering for specific layers, you can do the same thing:
gpcode(0) = 8: dataValue(0) = "0,Layer1,Layer2"

HTH,
Jeff

"Tom Roberts" wrote in message
news:4931798@discussion.autodesk.com...
Hello Bernard

To loop thro' a selection use something like the following:

Dim Ent As AcadEntity
Dim SS As AcadSelectionSet

For Each Ent In SS
'do something here...ie change colour
Ent.color = acCyan
Next Ent

To include hatches you need to add the OR operator to your selectionset
filter. You have got a filter working haven't you???
If not it looks something like this:

'set up filter data
gpCode(0) = -4: dataValue(0) = " gpCode(1) = -4: dataValue(1) = " gpCode(2) = 0: dataValue(2) = "LINE" 'filter for line
entities...
gpCode(3) = 0: dataValue(3) = "HATCH" 'or hatched entities...
gpCode(4) = -4: dataValue(4) = "OR>" 'close OR operator
gpCode(5) = 62: dataValue(5) = "6" 'that are colour magenta
(6)
gpCode(6) = -4: dataValue(6) = "AND>" 'close AND operator

Did you look up selection methods in the help file at all...
If you want to select via a window when your program will provide the window
coords use the SELECT method of the SelectionSet object.
If you want the User to enter the window use the SelectOnScreen method of
the SelectionSet object.
Both methods accept the filter as a parameter.

Keep at it. If you have any more problems post some code and will get it
nutted

--
Regards
Tom Roberts
__________________________
MechWest Design & Drafting
Perth, Western Australia




wrote in message news:4930933@discussion.autodesk.com...
Having a hard time looping through selection set and I want to also include
hatches.

Also, what's the line of code that asks for user to input a selection box
(upper left corner to lower right corner)

Bernard
0 Likes
Message 6 of 6

Anonymous
Not applicable
v. nice Jeff...I didn't think of that
Thanks.

--
Regards
Tom Roberts
__________________________
MechWest Design & Drafting
Perth, Western Australia



"Jeff Mishler" wrote in message
news:4931800@discussion.autodesk.com...
the filters can be simplified:
gpCode(0) = 0: dataValue(0) = "LINE,HATCH"
gpCode(1) = 62: dataValue(1) = 6

If you group like Objects into the same string, seperated by a comma it
implies OR
The SS function uses AND unless told otherwise. So the filters above will be
read by the SS function as "If an object is a Line OR Hatch, AND it is the
color 6, include it.

When filtering for specific layers, you can do the same thing:
gpcode(0) = 8: dataValue(0) = "0,Layer1,Layer2"

HTH,
Jeff

"Tom Roberts" wrote in message
news:4931798@discussion.autodesk.com...
Hello Bernard

To loop thro' a selection use something like the following:

Dim Ent As AcadEntity
Dim SS As AcadSelectionSet

For Each Ent In SS
'do something here...ie change colour
Ent.color = acCyan
Next Ent

To include hatches you need to add the OR operator to your selectionset
filter. You have got a filter working haven't you???
If not it looks something like this:

'set up filter data
gpCode(0) = -4: dataValue(0) = " gpCode(1) = -4: dataValue(1) = " gpCode(2) = 0: dataValue(2) = "LINE" 'filter for line
entities...
gpCode(3) = 0: dataValue(3) = "HATCH" 'or hatched entities...
gpCode(4) = -4: dataValue(4) = "OR>" 'close OR operator
gpCode(5) = 62: dataValue(5) = "6" 'that are colour magenta
(6)
gpCode(6) = -4: dataValue(6) = "AND>" 'close AND operator

Did you look up selection methods in the help file at all...
If you want to select via a window when your program will provide the window
coords use the SELECT method of the SelectionSet object.
If you want the User to enter the window use the SelectOnScreen method of
the SelectionSet object.
Both methods accept the filter as a parameter.

Keep at it. If you have any more problems post some code and will get it
nutted

--
Regards
Tom Roberts
__________________________
MechWest Design & Drafting
Perth, Western Australia




wrote in message news:4930933@discussion.autodesk.com...
Having a hard time looping through selection set and I want to also include
hatches.

Also, what's the line of code that asks for user to input a selection box
(upper left corner to lower right corner)

Bernard
0 Likes