Jump to content

Lisp to search layers and changing the lineweight


Recommended Posts

Posted

Is it possible to modify this lisp routine to select layer line weight and modify? example...current line weight .13 and change to .7

 

 

reason: want to have different viewport with different line weights base on viewport scale. line weight thicker on detail versus plan.

 

 

Hope someone can help.

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    13

  • Quattro_Trip

    8

  • popo1

    4

  • ILoveMadoka

    2

Posted

Here is a very simple program to map layer lineweights:

(defun c:lwmap ( / itm map )
   (setq map
      '(
           [color=red](013 070)[/color]
       )
   )
   (vlax-for lay (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
       (if (setq itm (assoc (vla-get-lineweight lay) map))
           (vla-put-lineweight lay (cdr itm))
       )
   )
   (princ)
)
(vl-load-com) (princ)

Add items to the 'map' list as necessary - be sure to follow the same format as the example highlighted in red above.

Posted
Here is a very simple program to map layer lineweights:

(defun c:lwmap ( / itm map )
   (setq map
      '(
           [color=red](013 070)[/color]
       )
   )
   (vlax-for lay (vla-get-layers (vla-get-activedocument (vlax-get-acad-object)))
       (if (setq itm (assoc (vla-get-lineweight lay) map))
           (vla-put-lineweight lay (cdr itm))
       )
   )
   (princ)
)
(vl-load-com) (princ)

Add items to the 'map' list as necessary - be sure to follow the same format as the example highlighted in red above.

 

 

Hi Lee Mac,

Thank you for the quick reply.

 

 

I am very new to this and appreciate the help.

 

 

Does this work for different viewports on one layout? would this Routine run in each viewport separately? example....(0.13,0.7) in one viewport and (0.13,0.3) in another? sorry if I am not making myself clear.

Thanks again.

Posted

You're welcome popo1 -

 

Does this work for different viewports on one layout? would this Routine run in each viewport separately?

 

Sorry no - this program will change the layer lineweight globally in the drawing (as if you had altered it using the Layer Manager), I assume that you are looking for a viewport override?

Posted

Yes. I haven't been able to find a routine to change line weight without specifying a layer. I was hoping you could select a layer by its line weight property. Reason...someone in office creates new layer with colour green....we have a lisp routine which sets this colour to 0.3 automatically. what I was hoping is that there was a way to select any layer with a 0.3 line weight and change it. this could be done if all layers had their weight specified in layer name.

  • 2 weeks later...
Posted
Yes. I haven't been able to find a routine to change line weight without specifying a layer. I was hoping you could select a layer by its line weight property. Reason...someone in office creates new layer with colour green....we have a lisp routine which sets this colour to 0.3 automatically. what I was hoping is that there was a way to select any layer with a 0.3 line weight and change it. this could be done if all layers had their weight specified in layer name.

 

In saying this...can a lisp routine be written that when a layer is created it will take pen weight and add as suffix to layer name?

 

Any help here would be greatly appreciated.

  • 2 months later...
Posted

Lee,

 

Could you point me to a tutorial on how to run a script across multiple drawings? I'm in the same situation as ILoveMadoka. The code you wrote beautifully sets all of the layers to default. Now I'd like it to skim through all of the drawings.

 

I tried loading the objectdbx code and then modifying the second code you said to load to work like this one does but it wasn't working.

 

 

You're very welcome :)

 

For this particular task, I think the VL method is more concise, but the Vanilla method is likely to be faster.

 

Lee

Posted

Nevermind! I got it to work! That is waaayyyy faster than having something open and close each drawing. Thank you so much Lee!!!

Posted
Nevermind! I got it to work! That is waaayyyy faster than having something open and close each drawing. Thank you so much Lee!!!

 

That's excellent to hear controlsgirl - you're most welcome!

 

As you've gathered, ObjectDBX is a much faster technology than a basic Script engine which requires that each drawing is opened in the AutoCAD Editor before any operations can be performed - though, the technology is under-developed and does have its faults in some circumstances which I've discussed in other threads.

 

Nevertheless, I'm glad you were able to complete your task with the program!

 

Cheers,

 

Lee

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