Jump to content

Move Everything to a Custom Layer


Bobzy20

Recommended Posts

Hi

 

Does anybody know of a lisp routine that will change everything within Model space to a custom layer name (G541-M_General lighting) and also set the colour to white (7).

 

Also having it delete all the other un-used layers would be great too.

 

Thanks

 

Bob

Link to comment
Share on other sites

something like a manual version do on keyboard

make layer G541-M_General lighting with colour and Ltype

CHPROP "select all required" la G541-M_General lighting lt bylayer C Bylayer

 

Not tested

(defun sslighting ( / ss)
(setq ss (ssget "X" (list (cons 410 "Model"))))
(command "-layer" "M" "G541-M_General lighting" "c" 7 "G541-M_General lighting" "lT" "Continuous" 
"G541-M_General lighting" "S" "G541-M_General lighting" "")
(command "chprop" ss "" "La" "G541-M_General lighting")
)
(sslighting)

Edited by BIGAL
Link to comment
Share on other sites

Could a lisp routine possibly do the following?

 

1. Create a new layer called: G541-M_General lighting (layer defaults are fine).

2. Set it current.

3. Move all items in the drawing including layers within blocks onto the new layer.

4. Automatically run the set by layer command to bring everything back to its defaults.

5. Delete all other layers including any that are turned off or frozen.

6. Remove all wipeouts within the drawing.

7. Purge the drawing.

 

Perhaps I would need to pay somebody to write it.

 

Thanks

 

Bob

Link to comment
Share on other sites

Fixed 1 & 2 my fault "-layer" code updated.

 

Step 3 "search blocks to current layer"

 

4 ???

 

5 search delete layers need a version to check off and frozen

; Written by Mark Thomas

; This file contains 2 functions:

; del-layer will delete all objects on a selected layer and purge it

 

6

(setq ss (ssget "X" (list (cons 0 "WIPEOUT"))))
(command "erase" ss "")

 

7 -purge !!

Link to comment
Share on other sites

Thanks BIGAL, the code is getting better.

 

Step 3 - I will have a search on the net.

 

Step 4 - This command already exists in AutoCAD SETBYLAYER and was wondering if this could be incorporated into the code?

http://help.autodesk.com/view/ACDLT/2016/ENU/?guid=GUID-A9D9FF14-4EF6-4A25-B0F4-506C6B792E9E

 

Step 5 - I will have a search on the net.

 

Step 6 - I tried adding that code to my code but it doesn't work, perhaps I'm putting it in the wrong place.

 

Step 7 - Same as above.

Edited by Bobzy20
Link to comment
Share on other sites

This is what I have so far.

 

(defun c:cadqa ( / ss)

(setq ss (ssget "X" (list (cons 410 "Model"))))

(command "-layer" "M" "G541-M_General lighting" "c" 7 "G541-M_General lighting" "lT" "Continuous"

"G541-M_General lighting" "S" "G541-M_General lighting" "")

(command "chprop" ss "" "La" "G541-M_General lighting")

)

(cadqa)

Link to comment
Share on other sites

maybe this add layer

 

(setq  doc (vla-get-activedocument (vlax-get-acad-object))) ; open database

(vlax-for block (vla-get-blocks doc) 
(if (not (wcmatch (strcase (vla-get-name block) t) "*_space*")) 
(vlax-for ent block 
(vla-put-layer ent (getvar "clayer")) ; current layer
(vla-put-color ent 0) 
(vla-put-linetype ent "Bylayer") 
(vla-put-lineweight ent aclnwtbyblock) 
) ;_ end of vlax-for 
) ;_ end of if 
) ;_ end of vlax-for 
(vla-regen doc acactiveviewport) 

Link to comment
Share on other sites

Thanks for the code. I now have this:

 

................................................................................

 

defun c:cadqa ( / ss)

(setq ss (ssget "X" (list (cons 410 "Model"))))

(command "-layer" "M" "G541-M_General lighting" "c" 7 "G541-M_General lighting" "lT" "Continuous"

"G541-M_General lighting" "S" "G541-M_General lighting" "")

(command "chprop" ss "" "La" "G541-M_General lighting")

(setq doc (vla-get-activedocument (vlax-get-acad-object))) ; open database

(vlax-for block (vla-get-blocks doc)

(if (not (wcmatch (strcase (vla-get-name block) t) "*_space*"))

(vlax-for ent block

(vla-put-layer ent (getvar "clayer")) ; current layer

(vla-put-color ent 0)

(vla-put-linetype ent "Bylayer")

(vla-put-lineweight ent aclnwtbyblock)

) ;_ end of vlax-for

) ;_ end of if

) ;_ end of vlax-for

(vla-regen doc acactiveviewport)

(setq ss (ssget "X" (list (cons 0 "WIPEOUT"))))

(command "erase" ss "")

)

(cadqa)

 

................................................................................

 

Just need to add:

 

5. Delete all layers including any that are turned off or frozen.

 

7. Purge the drawing (-purge didnt seem to work)

Link to comment
Share on other sites

Routine runs with errors though, AutoCAD Text Window below

 

.................................................. ..............................

 

Command: CADQA

-layer

Current layer: "G541-M_General lighting"

Enter an option

[?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre

eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: M

Enter name for new layer (becomes the current layer) :

G541-M_General lighting Enter an option

[?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre

eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: c

New color [Truecolor/COlorbook] : 7

Enter name list of layer(s) for color 7 (white) :

G541-M_General lighting Enter an option

[?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre

eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: lT

Enter loaded linetype name or [?] : Continuous

Enter name list of layer(s) for linetype "Continuous"

lighting>: G541-M_General lighting Enter an option

[?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre

eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]: S

Enter layer name to make current or

Enter an option

[?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Fre

eze/Thaw/LOck/Unlock/stAte/Description/rEconcile]:

Command: chprop

Select objects: 52 found

Select objects:

Enter property to change

[Color/LAyer/LType/ltScale/LWeight/Thickness/TRansparency/Material/Annotative]:

La

Enter new layer name : G541-M_General lighting

Enter property to change

[Color/LAyer/LType/ltScale/LWeight/Thickness/TRansparency/Material/Annotative]:

Regenerating model.

Command: erase

Invalid option keyword.

; error: Function cancelled

 

.................................................. ..............................

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...