Jump to content

move all polylinew to a new layer


Guest

Recommended Posts

Hi i want to select all polylines from a drawing and move them in specific layer

(defun c:TEST ()
 (COMMAND "_layer" "_m" "SHAPE" "_c" "7" "" "_lw" "0.40" "" "") ; this is the new layer
 (ssget "_X" '((0 . "*POLYLINE"))) ; All Polylines are selected
)

I dont know do it !!!!!!

 

Any options?

 

Thanks

Edited by prodromosm
Link to comment
Share on other sites

The following should get the job done as expected but would ignore the polylines on locked layers.

(defun c:Ply2Lay (/ ss)
  (command "_layer" "_m" "SHAPE" "_c" "7" "" "_lw" "0.40" "" "")
  (and (setq ss (ssget "_X" '((0 . "*POLYLINE"))))
       ((lambda (int / sn lst)
          (while (setq int (1+ int)
                       sn  (ssname ss int)
                 )
            (setq lst (entget sn))
            (entmod (subst '(8 . "SHAPE") (assoc 8 lst) lst))
          )
        )
         -1
       )
  )
  (princ)
)


 

Link to comment
Share on other sites

Hi Tharwat. Thanks for the replay. I forgot something .I want to convert the global width to 0

 

(command "_.pedit" "_m" s "" "w" 0 "") ; global 0

can you help?

 

Thanks

Link to comment
Share on other sites

Here you go.

(defun c:Ply2Lay (/ ss)
  (command "_layer" "_m" "SHAPE" "_c" "7" "" "_lw" "0.40" "" "")
  (and (setq ss (ssget "_X" '((0 . "*POLYLINE"))))
       ((lambda (int / sn lst pos)
          (while (setq lst nil
                       int (1+ int)
                       sn  (ssname ss int)
                 )
            (foreach dxf (entget sn)
              (or (and (setq pos (vl-position (car dxf) '(8 40 41 43)))
                       (setq lst (cons (cons (car dxf) (nth pos '("SHAPE" 0.0 0.0 0.0))) lst))
                       )
                  (setq lst (cons dxf lst)))
              )
            (entmod (reverse lst))
            )
          )
         -1
       )
  )
  (princ)
) (vl-load-com)

 

  • Like 1
Link to comment
Share on other sites

Hi Tharwat. I want to ask something else about this code ,for education reasons.

 

if i have polylines and point and hatches in layer1 , layer2 ,layer3 and i want to move only the polylines from layer 1 to layer poly-1 ,the polylines from layer 2 to layer poly-2 and the polylines from layer 3 to layer poly-3 , how to change this code

 

(defun c:Ply2Lay (/ ss)
  (command "_layer" "_m" "SHAPE" "_c" "7" "" "_lw" "0.40" "" "")
  (and (setq ss (ssget "_X" '((0 . "*POLYLINE"))))
       ((lambda (int / sn lst pos)
          (while (setq lst nil
                       int (1+ int)
                       sn  (ssname ss int)
                 )
            (foreach dxf (entget sn)
              (or (and (setq pos (vl-position (car dxf) '(8 40 41 43)))
                       (setq lst (cons (cons (car dxf) (nth pos '("SHAPE" 0.0 0.0 0.0))) lst))
                       )
                  (setq lst (cons dxf lst)))
              )
            (entmod (reverse lst))
            )
          )
         -1
       )
  )
  (princ)
) (vl-load-com)

Thanks

Link to comment
Share on other sites

Do some home work about the SSGET command and how filters work, you can have multiple filters as you want plines and a layer.

 

A simple method would be to pick an object on desired layer and get its layer name for use with ssget.

 

You do have 747 posts you should be by now able to do this simple modification to the very clear code provided. 

Edited by BIGAL
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...