LISP for adding callouts using multileaders

LISP for adding callouts using multileaders

rosader
Enthusiast Enthusiast
1,090 Views
7 Replies
Message 1 of 8

LISP for adding callouts using multileaders

rosader
Enthusiast
Enthusiast

Hello, I am trying to teach myself lisps but I am still brand new so I apologize in advance for the newbie question.

 

In our office, we currently have a collection of lisps that were created by a former employee. Right now I'm looking at the lisps for placing callouts such as detail callouts, post callouts, strap callouts etc.

The way these callout lisps work is it predefines point 1 and point 2 based on insertion point and selected angle then adds a line using those two points and then adds a callout head (dynamic block) at point 2. 

 

I'm not loving the idea of every callout being made up of a separate line and head. I would rather create a simpler lisp using multileaders to make it one single object.

 

I have already gone into our template and created multileader types for each type of callout (using the dynamic blocks rather than text)

 

I would like to modify the lisp to first select the multileader type, and then place the multileader from point 1 to point 2. Can anyone give me an idea if this is possible and what the lisp might look like? Thanks

0 Likes
Accepted solutions (1)
1,091 Views
7 Replies
Replies (7)
Message 2 of 8

Sea-Haven
Mentor
Mentor

If your already using a dynamic block you should be able to add further actions to it like move the bubble, but leave 1st point as is, also using visibilty helps as you can have multi arrow directions good for Left or right connection.

 

I am not good at dynamic blocks but there should be code and block out there that will be close.

 

SeaHaven_0-1668556810230.png

This block has 15 visibility states sorry a clients not mine, I just did an Insert front end.

 

Ps post code not image use the </> option

 

0 Likes
Message 3 of 8

ВeekeeCZ
Consultant
Consultant

Here's a simple concept.

 

(vl-load-com)


(defun c:Callouts ( / *error* cms :dictlist p s )
  
  (or *co-type*
      (setq *co-type* "Detail")) ; default

    (defun *error* (errmsg)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if cms (setvar 'cmleaderstyle cms))
    (vla-endundomark doc)
    (princ))
  
  (defun :dictlist (name / lst)
    (vlax-for dict (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object)))
      (and (vlax-property-available-p dict 'name)
	   (= (vla-get-name dict) name)
	   (vlax-for itm dict
	     (setq lst (cons (vla-get-name itm) lst)))))
    lst)


  (setq cms (getvar 'cmleaderstyle))
  
  (while (progn
	   (princ (strcat "\nCurrent type: " (strcase *co-type*)))
	   (initget "Detail Post Strap")
	   (setq p (getpoint "\nSpecify headpoint or CL type [Detail/Post/Strap]: ")))
    
    (if (listp p) 								; it's a point?
      (command-s "_mleader" "_non" p) 						; then make a callout

      (and (setq s (cdr (assoc p '(("Detail" 	.  "Detail")			; else, just set a style current.
				   ("Post" 	.  "Post-StyleFullname")	; get a style fullname
				   ("Strap" 	.  "StrapStyleFullname")))))
	   (or (vl-position s (:dictlist "ACAD_MLEADERSTYLE"))			; is it in the drawing?
	       (prompt "Error: Selected style does not exist in the drawing."))
	   (setq *co-type* p)							; set current style for prompt.
	   (setvar 'cmleaderstyle s))))						; then set it current

  (princ)
  )

 

Message 4 of 8

rosader
Enthusiast
Enthusiast

Currently all of our callout types have separate lisps because they have different applications. Some call for user to select angle, some are inserted perpendicular to a selected line, some add a rectangular boundary line based on two pick points then callout coming off the boundary line so I would like to keep them all as separate lisps.

 

I have the lisps kind of working but not all the way there yet.

It now adds a multileader from p1 to p2 but rather than using the mleader style specified in the lisp, it uses whatever multileader style is currently active in the drawing. So it works as long as I first manually set the correct style active but I would like to eliminate that extra step.

0 Likes
Message 5 of 8

ВeekeeCZ
Consultant
Consultant

All you're asking is in the code I have posted. So you just need to read...

BTW check your spelling, you can't have typos in the command names.

Message 6 of 8

rosader
Enthusiast
Enthusiast

Thank you. I'll have to look at it more in depth.

Sorry, I haven't had any formal training in lisps or code (I have watched some online videos) but it's definitely something I've become interested in.

I'm to the point that If I look at something long enough I can start to understand it piece by piece. I'm slowly making progress and will get good at it eventually. When I first started, none of it made any sense to me whatsoever.

 

Thanks again

0 Likes
Message 7 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

Here is a little extract from it. Just the important stuff.

 

- you need to make sure that the style you'r about to set current actually IS there in the drawing already.

- if your routine changes the current mld style, it should also restore it back if is done.

- the above should also be the case even in case of error... that could be just ESC break....

 

(vl-load-com)


(defun c:CallDetail ( / *error* cms :dictlist p s )
  
    (defun *error* (errmsg)  ; fall here in case of error. (ESC...¨)
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break,end"))
      (princ (strcat "\nError: " errmsg)))
    (if cms (setvar 'cmleaderstyle cms))
    (princ))
  
  (defun :dictlist (name / lst)  ; make a list of all mldstyle in the drawing.
    (vlax-for dict (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object)))
      (and (vlax-property-available-p dict 'name)
	   (= (vla-get-name dict) name)
	   (vlax-for itm dict
	     (setq lst (cons (vla-get-name itm) lst)))))
    lst)


  (setq cms (getvar 'cmleaderstyle))  ;;  set old 


  (setq style "Detail Callout")

  (if (vl-position style (:dictlist "ACAD_MLEADERSTYLE"))			; is it in the drawing?
    (setvar 'cmleaderstyle style)
    (prompt "Error: Selected style does not exist in the drawing."))


  
  (command "_.mleader" ....¨)

  

  (setvar 'cmleaderstyle cms))))						; then restore.

  (princ)
  )

 

0 Likes
Message 8 of 8

rosader
Enthusiast
Enthusiast

Thank You!

0 Likes