Jump to content

Recommended Posts

Posted

Hi,

I'm trying to fix som old drawings and want to create some new layers and move the existing lines to them. and the problem is with the last part, when i try to move a line (and the linetype doesent exist).

 

; Layer L1
(if (not (tblsearch "LAYER" "L1" ))
 (entmake (list
     (cons 0 "LAYER")
     (cons 100 "AcDbSymbolTableRecord")
     (cons 100 "AcDbLayerTableRecord")
     (cons 2 "L1")         ;Name
     (cons 70 0)           ;Freeze
     (cons 62 5)           ;Color (5 = Blue)
     (cons 6 "Continuous") ;LineType
     (cons 370 20)         ;Lineweight (20 = 0.20mm)
 ))
)

; Select "DOTLINE"
(if (setq lSet (ssget "_X" '((6 . "DOTLINE"))))
 (progn (sssetfirst nil lSet))
)

; Changes selected objects to Layer L1
(if (> (sslength lSet) 0)
 (command "_.chprop" (ssget ) "" "Layer" "L1" "Color" "ByLayer" "LType" "ByLayer" "LWeight" "ByLayer" "")
)

Posted

Try this code ...

 

(defun c:Test (/ l ss)
 (setq l "Layer1")  ; <= Change the layer name to your desired one
 (if (tblsearch "LAYER" l)
   (if (setq ss (ssget "_X" '((6 . "DOTLINE"))))
     ((lambda (j / sn e)
        (while
          (setq sn (ssname ss (setq j (1+ j))))
           (entupd
             (cdr
               (assoc
                 -1
                 (entmod
                   (subst (cons 8 l) (assoc 8 (entget sn)) (entget sn))
                 )
               )
             )
           )
        )
      )
       -1
     )
   )
   (princ (strcat "\n Layer name < " l " > is not found <!>"))
 )
 (princ)
)

Posted
Try this code ...

 

(defun c:Test (/ l ss)
 (setq l "Layer1")  ; <= Change the layer name to your desired one
 (if (tblsearch "LAYER" l)
   (if (setq ss (ssget "_X" '((6 . "DOTLINE"))))
     ((lambda (j / sn e)
        (while
          (setq sn (ssname ss (setq j (1+ j))))
           (entupd
             (cdr
               (assoc
                 -1
                 (entmod
                   (subst (cons 8 l) (assoc 8 (entget sn)) (entget sn))
                 )
               )
             )
           )
        )
      )
       -1
     )
   )
   (princ (strcat "\n Layer name < " l " > is not found <!>"))
 )
 (princ)
)

 

Thx,

I'm gonna try it first thing in the morning, my brain is killing me right now :)

Posted
Thx,

I'm gonna try it first thing in the morning, my brain is killing me right now :)

 

You're welcome .

 

Are you sure that you have the line type "DOTLINE" loaded into the LTYPE table ?

Posted
You're welcome .

 

Are you sure that you have the line type "DOTLINE" loaded into the LTYPE table ?

 

Yep, its some old drawings. probably around 25 years old, and they dident use any layers when they made them, so i'm trying to split the linetypes into different layers.

Posted
Yep, its some old drawings. probably around 25 years old, and they dident use any layers when they made them, so i'm trying to split the linetypes into different layers.

 

All right , Hope that my simple code would work for you as expected . :)

Posted (edited)

(defun c:test (/ Layer LSelect)
 (setq Layer "L1")
 (if (tblsearch "LAYER" Layer)
   (if (setq LSelect (ssget "_X" '((6 . "DOTLINE"))))
     (
       (lambda (j / sn e)
         (while
           (setq sn (ssname LSelect (setq j (1+ j))))
           (entupd
             (cdr
               (assoc
                 -1
                 (entmod
                   (subst (cons 8 Layer) (assoc 8 (entget sn)) (entget sn))
                 )
               )
             )
           )
         )
         (princ (strcat "\n <" (itoa (sslength LSelect)) "> object(s) moved to layer <" Layer ">"))
       )
       -1
     )
   )
   (princ (strcat "\n Layer name <" Layer "> is not found <!>"))
 )
 (princ)
)

 

Thx again,

I modified it alitte, gonna combind it with allot of other script later.

 

how do i change?

 

"Color" -> "ByLayer"

"LType" -> "ByLayer"

"LWeight" -> "ByLayer"

Edited by mekis
Posted

Try this ...

 

(defun c:test (/ Layer LSelect)
 (setq Layer "L1")
 (if (tblsearch "LAYER" Layer)
   (if (setq LSelect (ssget "_X" '((6 . "DOTLINE"))))
     ((lambda (j / sn)
        (while
          (setq sn (ssname LSelect (setq j (1+ j))))
           (entupd
             (cdr
               (assoc
                 -1
                 (entmod (append (entget sn)
                                 (list '(6 . "BYLAYER")
                                       '(370 . -1)
                                       '(62 . 256)
                                       (cons 8 Layer)
                                 )
                         )
                 )
               )
             )
           )
        )
      )
       -1
     )
   )
   (princ (strcat "\n Layer name <" Layer "> is not found <!>")
   )
 )
 (if LSelect
   (princ (strcat "\n <"
                  (itoa (sslength LSelect))
                  "> "
                  (if (> (sslength LSelect) 1)
                    "objects"
                    "object"
                  )
                  " moved to layer <"
                  Layer
                  ">"
          )
   )
 )
 (princ)
)

  • 7 years later...
Posted

Hi all, 

I am looking for a lisp program that can change the layer of line based on its linetype. All hidden line should be in "Hidden"layer. Dimensions in dimension layer, Bylayer in "Geometry" layer, All text in "text" layer. I tried above lisp but it didnt worked. I have very less knowledge of programming. Do we have any lisp existing which can make my work simple. Can anyone help me with it ?

 

Thanks a lot for your reply. 

 

Regards

Prashant

 

 

Posted

So you have a drawing (or drawings) that contains items with various linetypes, and you want a lisp routine to change the layer of every item (selected perhaps?) to a layer that has the same name as the linetype.

 

What about this scenario? You have a layer named "1234" whose linetype is HIDDEN and this layer contains 10 objects whose linetype is "ByLayer". So the objects appear with the HIDDEN linetype. If you change those objects to layer "Hidden" will the layer "Hidden" have the "Hidden" linetype also, or should the objects be forced to linetype "Hidden" at that point?

 

What about objects with the linetype Continuous? Will they go to a layer named Continuous?

 

  • 11 months later...
Posted
On 4/17/2020 at 11:48 PM, rkmcswain said:

So you have a drawing (or drawings) that contains items with various linetypes, and you want a lisp routine to change the layer of every item (selected perhaps?) to a layer that has the same name as the linetype.

 

What about this scenario? You have a layer named "1234" whose linetype is HIDDEN and this layer contains 10 objects whose linetype is "ByLayer". So the objects appear with the HIDDEN linetype. If you change those objects to layer "Hidden" will the layer "Hidden" have the "Hidden" linetype also, or should the objects be forced to linetype "Hidden" at that point?

 

What about objects with the linetype Continuous? Will they go to a layer named Continuous?

 

 

Thank you very much for your reply. I was able to solve the problem by self. 

Please consider the question as closed. 

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