Need a lisp code to change the Dim Line Line Weight Property of a Leader

Need a lisp code to change the Dim Line Line Weight Property of a Leader

Anonymous
Not applicable
1,764 Views
11 Replies
Message 1 of 12

Need a lisp code to change the Dim Line Line Weight Property of a Leader

Anonymous
Not applicable

I'm trying to create a small lisp routine to change the "Dim Line Lineweight" property of a group of Leaders on a drawing. The setting is located under properties in the Lines & Arrows section. I have the code I need to highlight all the leaders on a specific layer, but I cannot find the right code to change the line weight. Below is what I have so far. Thanks!

 

(defun c:Leader (/ ss)
(sssetfirst nil (ssget "_x" '((0 . "Leader")(8 . "TF_S_WELD SYMBOL"))))
(princ)
)

properties.png

0 Likes
Accepted solutions (2)
1,765 Views
11 Replies
Replies (11)
Message 2 of 12

ВeekeeCZ
Consultant
Consultant

Perhaps something like this:

 

(defun c:LeaderLW (/ ss lw i)
  
  (if (and (setq ss (ssget "_x" '((0 . "Leader"))))
	   (setq lw (getint "New LineWeight x100: "))
	   )
    (repeat (setq i (sslength ss))
      (setpropertyvalue (ssname ss (setq i (1- i))) "Dimlwd" lw)))
  (princ)
  )

 

BTW If you need to set some other property, just use the following code to see the name.

(dumpallproperties (car (entsel)))
0 Likes
Message 3 of 12

Anonymous
Not applicable

Thank you for the quick response. I just started learning lisp this morning, so I'm trying to understand what you have written.

If i want my new line weight to be "bylayer", would I just replace this: 

"New LineWeight x100: "

 Thanks!

0 Likes
Message 4 of 12

ВeekeeCZ
Consultant
Consultant
Accepted solution

No no, this it just a prompt for the user. And it requires an integer from the user to set. Try: (getint "Set integer: ")

 

But while now you want to set a fix value, then it can be much simpler:

 

(defun c:LeaderLWByLayer (/ ss i)

  (if (setq ss (ssget "_x" '((0 . "Leader")(8 . "TF_S_WELD SYMBOL"))))
    (repeat (setq i (sslength ss))
      (setpropertyvalue (ssname ss (setq i (1- i))) "Dimlwd" -1)))
  (princ)
  )

BTW The LineWeight property is a bit tricky. Try to copy that little snippet I added to the last post, set some LW to LEADER, run the code by copy-paste to command-line and watch the list of definition properties...

The first thing you can notice is that the value of LW is 100 times higher in definition than you can see in Properties Palette. And it's an integer in fact. The second this is about ByLayer and ByBlock which are represented by -1 or -2 value in definition..

0 Likes
Message 5 of 12

Anonymous
Not applicable

Thanks again, Bee!

 

I'm getting there, I think. I ran the code that you sent and it's telling me there is no function definition. Can you shed some light for me?

Thanks!

0 Likes
Message 6 of 12

ВeekeeCZ
Consultant
Consultant

The code is fine on my side. Which ACAD  version you have? The (setpropertyvalue) is supported since AutoCAD 2011.

 

Anyway, let's try another approach. Even the simpler - using the AutoCAD's Dimoverride function. 

(defun c:LeaderLWByLayer (/ ss)
  (if (setq ss (ssget "_x" '((0 . "Leader")(8 . "TF_S_WELD SYMBOL") )))
    (command "_.DIMOVERRIDE" "Dimlwd" -1 "" ss ""))
  (princ)
  )
0 Likes
Message 7 of 12

Anonymous
Not applicable

Thank you. The code from yesterday works too. I was just keying it into the command line incorrectly.

 

This has been a big help. I believe I can expand from here.

 

Thanks again!

0 Likes
Message 8 of 12

Anonymous
Not applicable

Hi Bee,

 

Quick question... in the code that you provided, how would I assign a specific value for the lineweight? For example, in place of the -1, I want to use 0.12mm thick for the line thickness.

 

Thank you!

 

(defun c:LeaderLWByLayer (/ ss i)

  (if (setq ss (ssget "_x" '((0 . "Leader")(8 . "TF_S_WELD SYMBOL"))))
    (repeat (setq i (sslength ss))
      (setpropertyvalue (ssname ss (setq i (1- i))) "Dimlwd" -1)))
  (princ)
  )

 

0 Likes
Message 9 of 12

ВeekeeCZ
Consultant
Consultant

Change it to 12.

It's stored as integers, 100 multiples.

0 Likes
Message 10 of 12

Anonymous
Not applicable

You had mentioned that in a previous thread, so i tried it. But, I'm not having any luck getting it to make the change. The code I'm using is below:

 

(defun c:LeaderLWByLayer4 (/ ss i)

(if (setq ss (ssget "_x" '((0 . "Leader")(8 . "*"))))
(repeat (setq i (sslength ss))
(setpropertyvalue (ssname ss (setq i (1- i))) "Dimlwd" 12)))
(princ)
)

0 Likes
Message 11 of 12

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... how would I assign a specific value for the lineweight? For example, in place of the -1, I want to use 0.12mm thick for the line thickness.....


 

From HELP for the DIMLWD System Variable:

 

Other valid values entered in hundredths of millimeters include 0, 5, 9, 13, 15, 18, 20, 25, 30, 35, 40, 50, 53, 60, 70, 80, 90, 100, 106, 120, 140, 158, 200, and 211.

All values must be entered in hundredths of millimeters. (Multiply a value by 2540 to convert values from inches to hundredths of millimeters.)

 

It looks like you'll have to settle for 0.13mm instead of 0.12mm.

Kent Cooper, AIA
0 Likes
Message 12 of 12

Anonymous
Not applicable

Thanks Kent and Bee,

 

I've been trying every combination under the sun to get that to work. When I changed it to 13, it worked perfectly.

 

Thanks again, Guys!!

0 Likes