Jump to content

Change Linetype


jmerch

Recommended Posts

Is there an easy way (probably LISP) to globally change objects where the linetype is set to Bylayer, and change the linetype to whatever the actual linetype of that layer is?

Link to comment
Share on other sites

(defun c:CLT () (c:ChangeLinetypes))

(defun c:ChangeLinetypes (/ ss layerItem lineType)
 (princ "CHANGE LINETYPES")
 (vl-load-com)
  (if
    (and (setq eName (car (entsel "\nSelect object on desired layer: ")))
         (setq ss
                (ssget "_x"
                       (list (setq layerName (assoc 8 (entget eName)))))))
     (if (and (setq layerItem
                     (vla-item (vla-get-layers
                                 (cond (*activeDoc*)
                                       ((setq *activeDoc*
                                               (vla-get-activedocument
                                                 (vlax-get-acad-object))))))
                               (vla-get-layer (vlax-ename->vla-object eName))))
              (= :vlax-false (vla-get-lock layerItem)))
       (progn
         (vla-startundomark *activeDoc*)
         (vlax-for x (setq ss (vla-get-activeselectionset *activeDoc*))
           (vla-put-linetype
             x
             (cond (lineType)
                   ((setq lineType (vla-get-linetype layerItem))))))
         (vla-delete ss)
         (vla-endundomark *activeDoc*))
       (prompt "** Layer is locked ** "))
     (prompt "\n** Nothing selected ** "))
 (princ))

Link to comment
Share on other sites

Is there an easy way (probably LISP) to globally change objects where the linetype is set to Bylayer, and change the linetype to whatever the actual linetype of that layer is?

 

I can't quite make sense of your request. If an object already has its linetype set to BYLAYER, there is no need to change it. Perhaps I am not reading it correctly, but RenderMan seems to be on the ball.

Link to comment
Share on other sites

I can't quite make sense of your request. If an object already has its linetype set to BYLAYER, there is no need to change it. Perhaps I am not reading it correctly, but RenderMan seems to be on the ball.

 

I agree with you; but I was bored, so I wrote it quickly anyways. LoL

 

Cheers! :beer:

Link to comment
Share on other sites

I do appreciate the LISP RenderMan! I'll give it a whirl today.

 

There is plenty reason to change the linetype from Bylayer. When I clean up architectural files I get in, I take their 500 layers and narrow them down into 6 of my own. Where they have all the linetypes set to Bylayer, I want it to be whatever it was originally on. Example, they may have 3 different furniture layers where 1 has a hidden linetype and the other two don't. I put all these onto 1 layer of mine but want each object to keep it's linetype and not become my Bylayer.

 

Make sense?

Link to comment
Share on other sites

I do appreciate the LISP RenderMan! I'll give it a whirl today.

 

There is plenty reason to change the linetype from Bylayer. When I clean up architectural files I get in, I take their 500 layers and narrow them down into 6 of my own. Where they have all the linetypes set to Bylayer, I want it to be whatever it was originally on. Example, they may have 3 different furniture layers where 1 has a hidden linetype and the other two don't. I put all these onto 1 layer of mine but want each object to keep it's linetype and not become my Bylayer.

 

Make sense?

 

The code I posted originally prompts the user to select an object, and results in all objects on that layer being modified. However, am I correct in my understanding that you are looking to open an external drawing, and simply modify all objects within that drawing (meaning for all layers)?

 

*IF* so, then I can improve the code I posted to no longer prompt you (the user) to select one layer at a time, and instead it (the code) will automatically implement this process for all objects (i.e., all layers) in sequence... your choice.

Link to comment
Share on other sites

Yes, I noticed your code. I have a similar code that I run to change layers per selection (mine isn't visual and is just dummied down LISP for me). I think I would like to have the change linetype be a global process that I can run in an entire drawing....I wasn't going to bother you with it and was going to play around with it today, but if you're not busy and don't mind :D :D

 

Really appreciate it.

Link to comment
Share on other sites

Yes, I noticed your code. I have a similar code that I run to change layers per selection (mine isn't visual and is just dummied down LISP for me).

 

No worries; we all start somewhere. :)

 

I think I would like to have the change linetype be a global process that I can run in an entire drawing....I wasn't going to bother you with it and was going to play around with it today, but if you're not busy and don't mind :D :D

 

Really appreciate it.

 

... Thought so; I'll post back the revised code shortly.

Link to comment
Share on other sites

Another slow day... I apologize if I've stepped on your toes, Mat.

 

(defun c:LT2All (/ ss i data layer lst)
 (if (setq ss (ssget "_X"))
   (repeat (setq i (sslength ss))
     (entmod
       (append
         (setq data (entget (ssname ss (setq i (1- i)))))
         (cond
           ((cadr (assoc (setq layer (cdr (assoc 8 data))) lst)))
           ((cadar (setq lst (cons (list layer (list (assoc 6 (tblsearch "LAYER" layer)))) lst))))
         )
       )
     )
   )
 )
 (princ)
)

It's your responsibility to unlock your layers. :wink:

Link to comment
Share on other sites

... Thought so; I'll post back the revised code shortly.

 

Another slow day...

 

I wasn't sure when I'd be done with my current task; Thanks Alan. :)

 

Separately (and offline?), you wouldn't want to share any pointers with me to help with my *pilot* "T" intersection corridor would you?

(^^ ya know, since you're slow and all :P ^^)

 

It's your responsibility to unlock your layers. :wink:

 

I think that's a prudent step; one that I should adopt as well (especially for forum code).

Link to comment
Share on other sites

  • 1 year later...

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