Are smart leaders possible in AutoCADLT2024

Are smart leaders possible in AutoCADLT2024

tktracy_wwrplacement
Contributor Contributor
889 Views
14 Replies
Message 1 of 15

Are smart leaders possible in AutoCADLT2024

tktracy_wwrplacement
Contributor
Contributor

Hello,

 

Our work flow involves annotating many lines (representing rebar) calling out their length, quantity, and layer. Is there anyway to automate a text leader to autofill this information of a selected line using a text field or something similar? I.E. if a line is drawn 20'-0" long on the "#4" layer and there are 3 of these lines, could we select the lines and generate a leader from this information?

 

Thank you, 

 

 

 

[ The subject line of this post has been edited for clarity by @pendean Change: added exact software being used ]

0 Likes
Accepted solutions (2)
890 Views
14 Replies
Replies (14)
Message 2 of 15

pendean
Community Legend
Community Legend
Nothing built-in does that in the two generic CAD choices you listed, but if you can share a DWG file with your content, in it also provide examples of your desired mleader text pointing to the correct objects, I'm sure folks around here could help you with some LISP customziations.

AutoCAD Advanced Steel may offer what you seek if you need something built-in (and so much more), it's free to install and use if you are a current AutoCAD (not LT) subscriber.
0 Likes
Message 3 of 15

tktracy_wwrplacement
Contributor
Contributor

Here is a sample of the reinforcement callouts as it is currently manually written, on this sample the lines are not on informative layers like mentioned above. Currently we are using LT2024 and I'm hopeful that it's new ability to use LISP's could help but if the solution needs the full version that is a possibility. 

0 Likes
Message 4 of 15

Sea-Haven
Mentor
Mentor

Yes can be done fairly simply using ssget "F" so you drag a selection line over objects it will get the length of say the 1st object, get the gap between could even be different, can lable that and how many then add a leader.

 

Just a comment for the re-entrant bars easier to use a block as they would in most cases be fixed sizes. So insert block and add the label. Can use a scale for length. 

 

The hardest past in the reo-bars is the 3rd leader line may need to be inputted manually as it varies. If the number of choices is limited to say 10-15 then a dcl can be used and pick correct 3rd line label. Please confirm.

 

SeaHaven_0-1695447134720.png

Just thinking the 3rd line.

SeaHaven_1-1695447548506.png

Can have up to about 20 buttons.

0 Likes
Message 5 of 15

tktracy_wwrplacement
Contributor
Contributor

Thank you for presenting this as an option. 

 

"ssget" does not appear as an option when typed into the command bar. Is there any option that has to be activate before it appears? We are on 2024 LT is it only in the full version?

 

Your right about the re-entrant bars that could just be a block as the length almost never changes. Although I assume you would need a attribute to be able to change the text on one callout without affecting the others.

 

If the select string works 10-15 choices would be plenty of options.

0 Likes
Message 6 of 15

pendean
Community Legend
Community Legend

@tktracy_wwrplacement @Sea-Haven SSGET as a command is not an option in LT2024 or older. Sorry.
As a LISP (SSGET) in a quick test seems to be available and working.

 

pendean_0-1695650867384.png

 

Message 7 of 15

tktracy_wwrplacement
Contributor
Contributor

Correct, with that said I'm not sure if the above will work. After I enter (ssget) and the count appears in the command bar I am not sure how to use that to autofill a leader.  

0 Likes
Message 8 of 15

pendean
Community Legend
Community Legend
Explore this tutorial http://www.lee-mac.com/ssget.html
0 Likes
Message 9 of 15

ВeekeeCZ
Consultant
Consultant

Possibly can start to build on this example....

 

(vl-load-com)

(defun c:Callin ( / l c s e y #num# #len# )
  
  (setq l '(
	    ("Loose Bar" . "(#num#) D23.3 x #len#\\P (1) E.F. @ T&B PANEL EDGES. TYP.")  
	    ("Layer2"    . "(#num#) D23.3 x #len#\\P (999) E.F. ")
	    )
	
	c '("#num#" "#len#"))
  
  (if (and (setq s (ssget '((0 . "LINE"))))
	   (setq e (ssname s 0))
	   (setq y (cdr (assoc 8 (entget e))))
	   (setq #len# (rtos (getpropertyvalue e "Length")))
	   (setq #num# (itoa (sslength s)))
	   (setq i (vl-some'(lambda (x) (if (= (car x) y) (cdr x))) l))
	   )
    (progn
      (foreach e c
	(while (vl-string-search e i)
	  (setq i (vl-string-subst (eval (read e)) e i))))
      (command "_.mleader" pause pause i)))
  (princ)
  )

 

0 Likes
Message 10 of 15

tktracy_wwrplacement
Contributor
Contributor

Thank you for this resource guide, I am also exploring a different path using fields and maybe some kind of diesel expression. Many of the object property's could be used to fill out the information i'm looking for. as shown below I have line length, I could also use line layer to fill out the bar size if I set up the layers correctly. Im new to diesel expressions but I understand they are like LISP but in fields, I could imagine one that could count selected lines and display the value. If anyone has input on how to write that. Also is it possible to link multiple field together? So that the line length field and layer field are updated together. 

tktracy_wwrplacement_0-1695660327530.png

 

.

0 Likes
Message 11 of 15

Sea-Haven
Mentor
Mentor
Accepted solution

My $0.05 there is lots of questions every label is different so not sure how to automate much more, a start would be use layer names D6 D233 etc. 

 

There are complications in the dwg like some linework is a block so have to explode before running. Its like you want a label style one or two or three, etc choose that 1st.

 

Just drag over the lines eg select 3 red lines. As per image above. 

 

(defun c:cntrebar ( / pt1 pt2 ss x b1 b2 d1 d2 gap)
(setq pt1 (getpoint "\npick 1st point over bars "))
(setq pt2 (getpoint pt1 "\nPick second point "))
(setq ss (ssget "F" (list pt1 pt2) '((0 . "LINE"))))
(if (= ss nil)
 (alert "Incorrect lines found ")
 (progn
  (setq cnt (sslength ss))
  (initget 1 "Yes No")
  (setq ans (getkword "\nDouble bars Yes No"))
  (if (= ans "Yes")(setq cnt (* cnt 2)))
  (prompt "\nPick start point for leader :")
  (if (>= (sslength ss) 2)
  (progn
   (setq b1 (vlax-ename->vla-object (ssname ss 0)))
   (setq b2 (vlax-ename->vla-object (ssname ss 1)))
   (setq len (vlax-get b1 'Length))
   (setq d1 (vlax-curve-getclosestpointto b1 pt1))
   (setq d2 (vlax-curve-getclosestpointto b2 pt1))
   (setq gap (distance d1 d2))
   (command "leader" pause pause pause "A" (strcat "(" (rtos  cnt 2 0) ") " "#d" " x " (rtos len 4 0) "\n" "@ " (rtos gap 4 0) ) "")
  )
  (progn
   (setq b1 (vlax-ename->vla-object (ssname ss 0)))
   (setq len (vlax-get b1 'Length))
   (command "leader" pause pause pause "A" (strcat "(" (rtos  cnt 2 0) ") " "#d" " x " (rtos len 4 0) ) "")
  )
  )
 )
)
(princ)
)
(c:cntrebar)

 

 

 

 

0 Likes
Message 12 of 15

harrison4SDLY
Community Visitor
Community Visitor

Thank you very much Sea-Haven,

 

This is very close to what I was asking for and i'm happy if this is the closest we can get to automated leaders.

But I have to ask if I had all the lines on their respective bar sizes "d23.3" "#4" etc, what would be the lisp code to references this instead of inserting the "#d" text?

 

Part 2 of my questions is on this part of the code 

(setq ans (getkword "\nDouble bars Yes No"))
  (if (= ans "Yes")(setq cnt (* cnt 2)))

 Could it be built off of to include "E.F." or "CTR" text in the leader based on if you answer yes or no?

 

Thank you again for your hard work.

0 Likes
Message 13 of 15

Sea-Haven
Mentor
Mentor

If the bars are on a layer #4 then can use that instead of the #d, I think in your sample all bars were on one layer.

 

 

(setq b1 (vlax-ename->vla-object (ssname ss 0)))
(setq lay (vlax-get b1 'layer))


"#d" now becomes lay

 

Not sure how to tackle the labelling. Can do stuff like this.

SeaHaven_0-1696306628225.png

 

 

0 Likes
Message 14 of 15

tktracy_wwrplacement
Contributor
Contributor

I have made some updates to LISP, It now generates total quantity, bar type based on layer name, length, number per face if E.F. and spacing. Here is the code:

 

(defun c:sleader ( / pt1 pt2 ss x b1 b2 d1 d2 gap layerName)
(setq pt1 (getpoint "\nPick 1st point over bars: "))
(setq pt2 (getpoint pt1 "\nPick 2nd point: "))
(setq ss (ssget "F" (list pt1 pt2) '((0 . "LINE"))))

(if (= ss nil)
(alert "Incorrect lines found.")
(progn
(setq cnt (sslength ss))
(initget 1 "Yes No")
(setq ans (getkword "\nDouble bars? (Yes/No): "))

; Get the layer name of the first selected line
(setq b1 (vlax-ename->vla-object (ssname ss 0)))
(setq layerName (vla-get-Layer b1))

(if (= ans "Yes")
(setq cnt1 (* cnt 2)) ; Double the main count when "Yes" is selected
(setq cnt1 cnt) ; Keep the main count as is when "No" is selected
)

(setq label (if (= ans "Yes") "E.F." "CTR"))

(prompt "\nPick start point for leader: ")

(if (>= (sslength ss) 2)
(progn
(setq b1 (vlax-ename->vla-object (ssname ss 0)))
(setq b2 (vlax-ename->vla-object (ssname ss 1)))
(setq len (vlax-get b1 'Length))
(setq d1 (vlax-curve-getclosestpointto b1 pt1))
(setq d2 (vlax-curve-getclosestpointto b2 pt1))
(setq gap (distance d1 d2))
(command "_.leader" pause pause pause "A" (strcat "(" (rtos cnt1 2 0) ") " layerName " x " (rtos len 4 0) "\n" "(" (itoa cnt) " " label ") " "@ " (rtos gap 4 0)) "")
)
(progn
(setq b1 (vlax-ename->vla-object (ssname ss 0)))
(setq len (vlax-get b1 'Length))
(command "_.leader" pause pause pause "A" (strcat "(" (rtos cnt1 2 0) ") " layerName " x " (rtos len 4 0) " (" (itoa cnt) " " label ")") "")
)
)
)
)
(princ)
)

(c:sleader)


Now I am very happy with this and would call it a success. I do have one last question, would it be possible to still detect bar type by layer name but have an optional prompt similar to the double bar question to override the name with a manual input? Example: selected bars are on a layer named D23.3 but I want leader to call them out D23.9 on one particular tag but on most other tag the default layer name if accurate.

 

Also thank you to everyone for there inputs!

0 Likes
Message 15 of 15

tktracy_wwrplacement
Contributor
Contributor
Accepted solution

I found Figured out my last request, attached it the latest code. Thank you all!! 

0 Likes