Explode, delete & change colour in modelspace & all viewports

Explode, delete & change colour in modelspace & all viewports

Anonymous
Not applicable
769 Views
2 Replies
Message 1 of 3

Explode, delete & change colour in modelspace & all viewports

Anonymous
Not applicable

I am trying to get same code that will explode dimensions, hatches, etc, then delete leftover hatches that cannot not exploded, send the wipeouts to back & then change colour & layer of everything.  I need this done in all drawing, in BOTH modelspace and paperspace across multiple layouts. I tried something like:

 

(if (setq ss (ssget "_X" '((0 . "DIMENSION,LEADER,MTEXT,HATCH"))))
(repeat (setq i (sslength ss))
(setq ename (ssname ss (setq i (1- i))))
(command "_.explode" ename)
)


)

(if (setq ss (ssget "_X" '((0 . "HATCH"))))
(repeat (setq i (sslength ss))
(setq ename (ssname ss (setq i (1- i))))
(command "_.erase" ename "")
)
)

(if (setq ss (ssget "_X" '((0 . "WIPEOUT"))))
(command "_.draworder" ss "" "")
)

 

(if (setq ss (ssget "_X"))
(command "_.chprop" ss "" "_layer" "0" "_c" "7" "")
)

 

but I keep getting the error: "1 was not in current space". Can anyone help?

0 Likes
Accepted solutions (1)
770 Views
2 Replies
Replies (2)
Message 2 of 3

dlanorh
Advisor
Advisor
Accepted solution

You are trying to do something (probably erasing) an object that is not in the current space, i.e. erase an object in paperspace whilst you are in modelspace. This happens because you are using (ssget "_X") incorrectly. You need to specify the current space as part of the filter string

(ssget "_X" ( list '(0 . "HATCH") (cons 410 (getvar 'ctab))))

and put all your code inside a loop that iterates through each layout

I am not one of the robots you're looking for

Message 3 of 3

Anonymous
Not applicable

Thanks, I appreciate your help.

0 Likes