Jump to content

change entity to layer


rookie37

Recommended Posts

Adesu wrote an excellent program for me. It's saves me an HUGE amount of work.

 

Adesu or somebody

Can you help me make it a little more user friendly?

 

At the moment, it picks (and will keep picking) a single entity

Can this be modified so if it misses an entity it will instead draw a box I can place around several objects?

 

Also, the program at the bottom lccl doesn't work. I don't know how to create a layer with a linetype

other than continous. center is loaded but it still doesn't work

 

;This program selcs a single at a entity

; at a time and changes it to a specific layer.

;If the layer doesn't already exist,

;it will create it as well

;Written by Donald Christensen with LOTS and LOTS of help

;thank you Adesu

 

 

 

;;;;;change layer;;;;;;;

 

(defun c:ldef (/ ss)

(while

(setq ss (car (entsel "\nSelect an object to move layer")))

(command "_layer" "m" "defpoints" "c" 8 "" "")

(command "_chprop" ss "" "la" "defpoints" "")

) ; while

(princ)

)

 

;;;concrete;;; example lc18 = (layer, concrete_018)

(defun c:lc18 (/ ss)

(while

(setq ss (car (entsel "\nSelect an object to move layer")))

(command "_layer" "m" "concrete_018" "c" "magenta" "" "")

(command "_chprop" ss "" "la" "concrete_025" "")

) ; while

(princ)

)

 

(; layer concrete Center Line

(defun c:lccl (/ ss)

(while

(setq ss (car (entsel "\nSelect an object to move layer")))

(command "_layer" "m" "concrete_cl" "c" "red" "l" "center" "" "")

(command "_chprop" ss "" "la" "concrete_025" "")

) ; while

(princ)

)

 

 

)

Link to comment
Share on other sites

Here's a modification to one routine to allow group selection. You can modify others like this if you like it.

 

(defun c:ldef (/ ss)
  (princ "\nSelect object to move to DEFPOINTS layer")
  (setq ss (ssget))
  (command "_layer" "m" "defpoints" "c" 8 "" "")
  (command "_chprop" ss "" "la" "defpoints" "")
  (princ)
)

 

And the problem with the centerline not showing may be because of the discrepancy between these 2 lines:

 

(command "_layer" "m" "concrete_cl" "c" "red" "l" "center" "" "")

(command "_chprop" ss "" "la" "concrete_025" "")

 

You need to use the same layer name in each.

 

Enjoy!

Link to comment
Share on other sites

Another oneЖ

(defun c:chlay (/ adoc ent selset lay)
 (vl-load-com)
 (vla-startundomark (vla-get-activedocument (vlax-get-acad-object)))
 (if (and (setq ent (car (entsel "\nPick an object <Cancel> : ")))
          (setq selset (ssget "_:L"))
          ) ;_ end of and
   (progn
     (setq lay (vla-get-layer (vlax-ename->vla-object ent)))
     (foreach item
              (mapcar 'vlax-ename->vla-object
                      (vl-remove-if 'listp (mapcar 'cadr (ssnamex selset)))
                      ) ;_ end of mapcar
       (vl-catch-all-apply '(lambda () (vla-put-layer item lay)))
       ) ;_ end of foreach
     ) ;_ end of progn
   ) ;_ end of if
 (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))
 (princ)
 ) ;_ end of defun

Link to comment
Share on other sites

CarlB

thank you for the program

 

The simple mistake on lccl was embarrasing. However when I fixed it, it still didn't work

 

 

(defun c:lccl (/ ss)

(princ "\nSelect object to move to concrete_cl layer")

(setq ss (ssget))

(command "_layer" "m" "concrete_cl" "c" "red" "l" "center" "" "")

(command "_chprop" ss "" "la" "concrete_cl" "")

(princ)

)

Link to comment
Share on other sites

Try this:

 

 
(defun c:lccl (/ ss)
(princ "\nSelect object to move to concrete_cl layer")
(setq ss (ssget))
(command "_.layer" "Make" "concrete_cl" "C" "1" "" "L" "center" "" "")
(command "_.chprop" ss "" "la" "concrete_cl" "")
(princ)
)

Link to comment
Share on other sites

  • 2 years later...

Here is a routine I use to draw leader or dims in a specific layer. If the layer does not exist then it create the layer. Just added to the end Cad64's SSget routine.

 

(defun c:cd(/ ss)

(setq oldlay(getvar "clayer")) ; Saves the current layer it is in

(if (null (tblsearch "layer" "NEWLAYER")) ; conditional if search of the layer table for specific layer

(command ".layer" "make" "NEWLAYER" "c" "30" "" "l" "Continuous" "" "") ; if not available then create it with the specific configurations

(setvar "clayer" "NEWLAYER") ; after new layer is created it sets it as the current layer

)

(princ "\nSelect object to move to NEWLAYER Layer:")

(setq ss (ssget))

(command "_.chprop" ss "" "la" "NEWLAYER" "")

(setvar "clayer" oldlay)

(princ))

Link to comment
Share on other sites

And yet another variety:

 

[b][color=BLACK]([/color][/b]defun c:ldef [b][color=FUCHSIA]([/color][/b]/ lay ldef flag ss[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq lay [color=#2f4f4f]"DEFPOINTS"[/color][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.LAYER"[/color][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]not [b][color=MAROON]([/color][/b]tblsearch [color=#2f4f4f]"LAYER"[/color] lay[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b]command [color=#2f4f4f]"_Make"[/color] lay[b][color=NAVY])[/color][/b]
     [b][color=NAVY]([/color][/b]progn
       [b][color=MAROON]([/color][/b]setq ldef [b][color=GREEN]([/color][/b]tblsearch [color=#2f4f4f]"LAYER"[/color] lay[b][color=GREEN])[/color][/b]
             flag [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 70 ldef[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
       [b][color=MAROON]([/color][/b]and [b][color=GREEN]([/color][/b]= [b][color=BLUE]([/color][/b]logand flag  1[b][color=BLUE])[/color][/b]  1[b][color=GREEN])[/color][/b]
            [b][color=GREEN]([/color][/b]command [color=#2f4f4f]"_Thaw"[/color] lay[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
       [b][color=MAROON]([/color][/b]and [b][color=GREEN]([/color][/b]minusp [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 62 ldef[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
            [b][color=GREEN]([/color][/b]command [color=#2f4f4f]"_On"[/color] lay[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
       [b][color=MAROON]([/color][/b]and [b][color=GREEN]([/color][/b]= [b][color=BLUE]([/color][/b]logand flag  4[b][color=BLUE])[/color][/b]  4[b][color=GREEN])[/color][/b]
            [b][color=GREEN]([/color][/b]command [color=#2f4f4f]"_Unlock"[/color] lay[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
       [b][color=MAROON]([/color][/b]command [color=#2f4f4f]"_Set"[/color] lay[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]""[/color][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]not ss[b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]princ [b][color=MAROON]([/color][/b]strcat [color=#2f4f4f]"\nSelect Entities To Change To Layer "[/color] lay [color=#2f4f4f]":   "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]if [b][color=RED]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=RED])[/color][/b]
                                  [b][color=RED]([/color][/b]cons 410 [b][color=PURPLE]([/color][/b]getvar [color=#2f4f4f]"CTAB"[/color][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b]
                                  [b][color=RED]([/color][/b]cons 67 [b][color=PURPLE]([/color][/b]- 1 [b][color=TEAL]([/color][/b]getvar [color=#2f4f4f]"TILEMODE"[/color][b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.CHANGE"[/color] ss [color=#2f4f4f]""[/color] [color=#2f4f4f]"_P"[/color] [color=#2f4f4f]"_LA"[/color] lay [color=#2f4f4f]""[/color][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

-David

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...