Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How convert a Spline to a curved leader

15 REPLIES 15
Reply
Message 1 of 16
Anonymous
1174 Views, 15 Replies

How convert a Spline to a curved leader

Does anybody have code to convert a spline or read its points so I can create a curved leader (with arrowhead) reasonably close ??? Thanks, Scott McFarren
15 REPLIES 15
Message 2 of 16
Anonymous
in reply to: Anonymous

You can export it to an R12 dxf, open the dxf and save it as a drawing, then insert it into you original drawing exploded. "Scott Mcfarren" wrote in message news:415093f2$1_3@newsprd01... > Does anybody have code to convert a spline or read its points so I can > create > a curved leader (with arrowhead) reasonably close ??? > > Thanks, > > Scott McFarren > >
Message 3 of 16
Anonymous
in reply to: Anonymous

This will get fairly close. There is no error checking and the arrowhead is separated from the leader when finished. (defun c:mkleader () (setq ename (car (entsel "\nSelect spline: "))) (setq ptlist nil) (setq ecnt 0 elen (length (entget ename))) (while (< ecnt elen) (setq element (nth ecnt (entget ename))) (if (equal (car element) 10) (setq ptlist (cons (cdr element) ptlist)) );end setq (setq ecnt (1+ ecnt)) );end while (setq ptlist (reverse ptlist)) (command ".leader") (foreach x ptlist (command x) ) (command "" "o" "" ".erase" (entlast) "" ".explode" (entlast) ".pedit" (entlast) "spline" "" ) (princ) ) "Scott Mcfarren" wrote in message news:415093f2$1_3@newsprd01... > Does anybody have code to convert a spline or read its points so I can > create > a curved leader (with arrowhead) reasonably close ??? > > Thanks, > > Scott McFarren > >
Message 4 of 16
Anonymous
in reply to: Anonymous

Thanks Jim. I'll give it a try. Scott "Jim Claypool" wrote in message news:4150ba6b$1_3@newsprd01... > This will get fairly close. > There is no error checking and > the arrowhead is separated from the leader when finished. > > (defun c:mkleader () > (setq ename (car (entsel "\nSelect spline: "))) > (setq ptlist nil) > (setq ecnt 0 elen (length (entget ename))) > (while (< ecnt elen) > (setq element (nth ecnt (entget ename))) > (if (equal (car element) 10) > (setq ptlist (cons (cdr element) ptlist)) > );end setq > (setq ecnt (1+ ecnt)) > );end while > (setq ptlist (reverse ptlist)) > (command ".leader") > (foreach x ptlist > (command x) > ) > (command > "" "o" "" > ".erase" (entlast) "" > ".explode" (entlast) > ".pedit" (entlast) "spline" "" > ) > (princ) > ) > > "Scott Mcfarren" wrote in message > news:415093f2$1_3@newsprd01... > > Does anybody have code to convert a spline or read its points so I can > > create > > a curved leader (with arrowhead) reasonably close ??? > > > > Thanks, > > > > Scott McFarren > > > > > >
Message 5 of 16
Anonymous
in reply to: Anonymous

Scott:

A2K4 does have an option under the Leader Line & Arrow TAB/ Leader Line, for a Spline Leader. Is this not what you want to be able to do?
Message 6 of 16
HS20EXR
in reply to: Anonymous

Hi Scott,

 

Very nice program, works well. I was trying to adapt it a little to draw a spline and the leader in one step, so I won't have to draw the spline and then to run the program to select the spline to turn it into a leader. Unfortunately, I wasn't able to do that. Do you think you could help? I appreciate it.

Message 7 of 16
Kent1Cooper
in reply to: Anonymous


@HS20EXR wrote:

 

Very nice program, works well. I was trying to adapt it a little to draw a spline and the leader in one step, so I won't have to draw the spline and then to run the program to select the spline to turn it into a leader. Unfortunately, I wasn't able to do that. Do you think you could help? I appreciate it.


What version do you have?  Does it not have the Spline option in the Leader or Qleader command?  In the Leader command, for some unknown reason it's after you've given it the second point that you get the Format option, within which is the Spline option.  In Qleader, call for Settings.  There may be other possible ways to get at it, depending on version.

Kent Cooper, AIA
Message 8 of 16
HS20EXR
in reply to: Kent1Cooper

I have AutoCAD 2011. I don't use Leader command at all and I didn't want to change the Settings in QLeader because I'm using Qleader (LE) for straight leaders more often than spline leaders. I was looking for a separate LISP program for spline leaders and  I like Jim Claypool's, but works in two steps, one to draw the spline and second to run the program to add the arrow to it. It's not bad but I think it can be improved, adding some code to draw the spline inside the program and then to be selected automatically and turned into a leader. My LISP skills are pretty poor and I couldn't make it but I don't think it would be difficult for someone with good LISP skills to edit the program. I spent lots of time and I just couldn;t make it work.

Thank you for your reply.

Message 9 of 16
Kent1Cooper
in reply to: HS20EXR

How about something as simple as this:

 

(defun C:SLDR (); = Spline LeaDeR

  (command "_.leader" pause pause "_format" "_spline")

)

Kent Cooper, AIA
Message 10 of 16
HS20EXR
in reply to: Kent1Cooper

It works nicely but I avoid using leaders because they prompt for adding text at the end of the command and it's "difficult" to exit the command without adding text. I move text around and I draw leaders after the text. I get more flexibility this way. That's why I prefer QLeaders over Leaders. 

This is Jim Claypool's program in an easier legible form. I added a line to delete the last object, it drew a pline over the original spline. If you could take a quick look and see a way of adding code for drawing a spline inside the program would be nice. 

Thank you for your help anyway, Master Cooper!

 

(defun c:sple () ;;SPlineLEader

(setq ename (car (entsel "\nSelect spline: ")))
(setq ptlist nil)
(setq ecnt 0 elen (length (entget ename)))
(while (< ecnt elen) (setq element (nth ecnt (entget ename)))
(if (equal (car element) 10) (setq ptlist (cons (cdr element) ptlist)) );end setq
(setq ecnt (1+ ecnt)) );end while
(setq ptlist (reverse ptlist))
(command ".leader")
(foreach x ptlist (command x) )
(command "" "o" ""
".erase" (entlast) ""
".explode" (entlast)
".pedit" (entlast) "spline" "" )
(command "erase" "L" "") ;added
(princ)
)

Message 11 of 16
Kent1Cooper
in reply to: HS20EXR


@HS20EXR wrote:

.... I avoid using leaders because they prompt for adding text at the end of the command and it's "difficult" to exit the command without adding text. ....


That's not what's difficult, in my opinion.  This will do that part quite handily:

 

(defun C:test (/ pt)
  (command "_.leader" pause pause "_format" "_spline")
  (while (setq pt (getpoint (getvar 'lastpoint) "\nSpecify next point: "))
    (command pt); feed out to Leader command
  ); end while [loop ended by Enter/space instead of picking point]
  (command "" "" "_none")
)

 

The difficult [maybe impossible?] part, in my trials, is to get it to show you the Leader under construction along the way.  The above collects points, and afterwards builds a spline-format Leader, with no text, based on them.  I tried various things in an attempt to see it in progress, but so far without success.

Kent Cooper, AIA
Message 12 of 16
HS20EXR
in reply to: Kent1Cooper

It works fine, you made it look easy. It's an ingenious solution. This comes very close to what I am looking for. Of course, in theory it would be better to see the leader under construction along the way but that's not really an issue. Practically, it works fine, it's easy to predict what it would look like, it's usually made of 3-4 points. I'll start using it today.

I appreciate it, thank you Master Cooper.

 

Message 13 of 16
Kent1Cooper
in reply to: HS20EXR


@HS20EXR wrote:

It works fine, you made it look easy. It's an ingenious solution. This comes very close to what I am looking for. Of course, in theory it would be better to see the leader under construction along the way but that's not really an issue. Practically, it works fine, it's easy to predict what it would look like, it's usually made of 3-4 points. I'll start using it today.

I appreciate it, thank you Master Cooper.

 


You're welcome.  If, like me, you draw with Blipmode on, you can at least see the points you've picked, and get a pretty good feel for what the Leader is going to look like, as you go.

Kent Cooper, AIA
Message 14 of 16
HS20EXR
in reply to: Kent1Cooper

I don't draw with BLIPMODE on, but you gave me the idea to turn it on for this program only and then go back to BLIPMODE off. 

 

(defun C:Test (/ pt)

(setq blipmode (getVAR "BLIPMODE"));; this is 0 usually

(defun *error* (msg)
(princ msg)
(setvar "BLIPMODE" blipmode)
;(setvar "BLIPMODE" 0)
(princ))

(setvar "BLIPMODE" 1)
(command "_.leader" pause pause "_format" "_spline")
(while (setq pt (getpoint (getvar 'lastpoint) "\nSpecify next point: "))
(command pt); feed out to Leader command
); end while [loop ended by Enter/space instead of picking point]
(command "" "" "_none")
;; (setvar "BLIPMODE" 0) ;reset BLIPMODE
(setvar "BLIPMODE" blipmode) ;reset BLIPMODE- this should be 0 
)

 

The thing is if I hit ESC repetitively after I pick a few points BLIPMODE doesn't reset to 0 (which I expect) but stays on. I guess it's not an error so the error code doesn't run and the last line of code that resets the BLIPMODE to initail value (which is 0) doesn't run either. Would you know how to fix that?

 

 

Message 15 of 16
Ian_Bryant
in reply to: HS20EXR

Hi,

you could try something like:

(defun c:test ()

(setvar "cmdecho" 1) (setvar "nomutt" 0)

(command "_.leader" pause pause "_format" "_spline" pause)  (terpri)

(while

   (and

     (/= (getvar "cmdactive") 0)

     (/= (getvar "LASTPROMPT") "Enter first line of annotation text or <options>:")

   )

   (command pause) (terpri)

)

(command  "" "_none")

(princ)

)

Ian

Message 16 of 16
HS20EXR
in reply to: Ian_Bryant

This works perfectly. Many thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost