Hello,
I have been trying different thing and cant figure it out and need some help.
We have made several revisions to plans and have several deltas and bubbles on the sheets and the bubbles and deltas are the same layer (I.E. for Revision 1 the bubbles and deltas are RV1 layer, Revision 2 the bubbles and deltas are RV2 layer).
Is there a way to find each block (delta) with a certain layer and change the layer to a new layer without affecting the bubble's layer. Also is it able to not get hung up if there is an RV2 and RV4 but no RV1 or RV3?
Basically we need to change the delta or bubble (whichever is easier) to its own layer, like RV1DELTA (or something in that area).
We have a bunch of sheets like this is why I am looking for a lisp routine or something that can help so I dont have to go into each sheet and create a new layer one by one for each revision layer. The Deltas are blocks and the bubbles are not, if that helps. (BLOCK NAME: TRINOTE, BLOCK TAG: ?TRINOTE)
I am also hoping I can batch this for all of the drawings inside the folder so I dont have to open every single one but trying to get the initial layer change down first.
Please let me know if you need more information.
Thanks!
@Anonymous wrote:
...
We have made several revisions to plans and have several deltas and bubbles on the sheets and the bubbles and deltas are the same layer (I.E. for Revision 1 the bubbles and deltas are RV1 layer, Revision 2 the bubbles and deltas are RV2 layer).
Is there a way to find each block (delta) with a certain layer and change the layer to a new layer without affecting the bubble's layer. Also is it able to not get hung up if there is an RV2 and RV4 but no RV1 or RV3?
Basically we need to change the delta or bubble (whichever is easier) to its own layer, like RV1DELTA (or something in that area).
.... (BLOCK NAME: TRINOTE, BLOCK TAG: ?TRINOTE)
....
Something like this is one way [untested]:
(if (setq ss (ssget "_X" '((0 . "INSERT") (2 . "TRINOTE")))); find any such Blocks
(repeat (setq inc (sslength ss))
(setq
blk (ssname ss (setq inc (1- inc)))
lay (strcat (cdr (assoc 8 (entget blk))) "DELTA"); new Layer name
); setq
(command
"_.layer" "_make" lay "" ; will make if it doesn't exist, & set current either way; won't care if it already exists
"_.chprop" blk "" "_layer" lay "" ; put that Block on that Layer
); command
); repeat
); if
Awesome! This worked.
Now I am writing in to freeze the bubble only and its freezing the delta too because of the names... just need it to ignore the deltas.
Edit: Got it to work woith only freezing the bubbles.
Looks like it hangs up when there are bubbles in both model and paper space.. If you run it in model space it will work for all in model space but it will not work if you do this in paper space. Any suggestions?
Error: The object is not in current space.
@Anonymous wrote:
Looks like it hangs up when there are bubbles in both model and paper space.. If you run it in model space it will work for all in model space but it will not work if you do this in paper space. Any suggestions?
Error: The object is not in current space.
Editing commands like CHPROP, in (command) functions, can only "find" things that are in the current space. If there might be some in other spaces, and you also want those moved to the other Layer, then you would need to either change to their space to CHPROP them, or use (subst)/(entmod) or (vla-put-Layer...) instead of CHPROP to change their Layer. I can work that out tomorrow if you don't figure it out yourself first.
I thought I could get the entmod by trial and error (never tried it before) but cant. Sorry.
Also, If the *Delta layer is already created is there a way to ignore creating the layer again (since itll be called *DeltaDelta and just set the "blk" to the already created layer? There will be occasions where we have already ran this command and need to do it again.
Thanks for the help. I will read more into the entmod and see if I can learn it better.
As for the not looking for the already made block on the "*Delta" layer, can I put (not (8. "DELTA") in the ssget sequence?
Just trying to learn while I go..
Thanks!
@Anonymous wrote:
As for the not looking for the already made block on the "*Delta" layer, can I put (not (8. "DELTA") in the ssget sequence?
Just trying to learn while I go..
Thanks!
YES
(setq ss (ssget "_X" '((0 . "INSERT") (2 . "TRINOTE")(-4 . "<NOT") (8 . "*DELTA") (-4 . "NOT>"))))
@Anonymous wrote:
- Ah! I read some more and do see that now.. Thanks!! Now I just gotta figure out the whole subst and entmod.
It's just a matter of replacing the Layer entry (assoc 😎 in the entity data with one using the new Layer name. Something like this ought to do it [again, untested]:
(if (setq ss (ssget "_X" '((0 . "INSERT") (2 . "TRINOTE") (-4 . "<NOT") (8 . "*DELTA") (-4 . "NOT>")))); find any such Blocks
(repeat (setq inc (sslength ss))
(setq
blk (ssname ss (setq inc (1- inc)))
blkdata (entget blk)
lay (strcat (cdr (assoc 8 blkdata)) "DELTA"); new Layer name
); setq
(command "_.layer" "_make" lay "") ; will make if it doesn't exist, & set current either way; won't care if it already exists
(entmod (subst (cons 8 lay) (assoc 8 blkdata) blkdata))
); repeat
); if
The other approaches I mentioned in Message 5 are also available.
@Kent1Cooper wrote:(command "_.layer" "_make" lay "") ; will make if it doesn't exist, & set current either way; won't care if it already exists
(entmod (subst (cons 8 lay) (assoc 8 blkdata) blkdata))
There is no need to call the LAYER command as entmod will automatically add the layer to the Layer Table if it doesn't already exist.