need help with a lisp

need help with a lisp

Anonymous
Not applicable
980 Views
8 Replies
Message 1 of 9

need help with a lisp

Anonymous
Not applicable

Have a simple routine i wrote for a loop leader. When I am picking point a b c  it would be nice to see the line I will be drawing so I could make the landing of the leader straight. Any assistance would be great.

 

(defun c:ll ()
(command "-layer""make""E-ANNO-TEXT""")
(setq a (getpoint "\nEnter First Point : "))
(setq b (getpoint "\nEnter Second Point : "))
(setq c (getpoint "\nEnter third Point : "))
(command "pLine" a b c "")
(command "arc""END"PAUSE)
(princ))

0 Likes
Accepted solutions (1)
981 Views
8 Replies
Replies (8)
Message 2 of 9

ToanDN
Consultant
Consultant
Is a simple Qleader w/ custom loop arrow block not an option?
0 Likes
Message 3 of 9

Anonymous
Not applicable

no its not an option. The qleader has a block attached to it. this is not a block and the end of the leader can be sized differently.  Currently we have a leader head for the quick leader and a leader head for the mleader. I don't want a block at the end .

0 Likes
Message 4 of 9

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... When I am picking point a b c  it would be nice to see the line I will be drawing so I could make the landing of the leader straight. ....

....

(setq a (getpoint "\nEnter First Point : "))
(setq b (getpoint "\nEnter Second Point : "))
(setq c (getpoint "\nEnter third Point : "))
....


The (getpoint) function has an option for a [pt] argument, for a point from which it will show a rubber-band indicator.

....

(setq a (getpoint "\nEnter First Point : "))
(setq b (getpoint a "\nEnter Second Point : "))
(setq c (getpoint b "\nEnter third Point : "))

....

Kent Cooper, AIA
Message 5 of 9

ВeekeeCZ
Consultant
Consultant

Another way is using the PLINE command directly:

 

Spoiler
(defun c:LL ( / *error* oCLAYER Layer) 

  (defun *error* (errmsg) ;Error function where program automatically falls when is ERROR or ESC ending
    (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
      (princ (strcat "\nError: " errmsg)))
    (setvar 'CLAYER oCLAYER) ;returs previous value of sysvar
    (princ)
  )

  (setq oCLAYER (getvar 'CLAYER) ;store sysvar for return
	Layer "E-ANNO-TEXT") 	 ;set name of your layer

  (if (tblsearch "LAYER" Layer) ;if this layer already exists
    (setvar 'CLAYER Layer) 	;set it as current
    (command "_.-LAYER" "_M" Layer "_C" 1 Layer "")) ;otherwise create it.

  (while T  		;END LOOP WITH ESC (if you dont want a loop erase this line)
    (command "_.PLINE" PAUSE PAUSE PAUSE "")
    (command "_.ARC" "_END")
    (while (> (getvar 'CMDACTIVE) 0)
      (command PAUSE))
    ) 			;(if you dont want a loop erase this line)

  (setvar 'CLAYER oCLAYER) 	;not necessary if is a loop
  (princ) 			;not necessary if is a loop 
)

 

0 Likes
Message 6 of 9

Kent1Cooper
Consultant
Consultant

Looking at this in a little more detail, it looks as though the Arc part is supposed to be for an arc segment to end the Polyline with, not an Arc command to make an Arc entity.  [If there's an End option in the first prompt in Arc in newer versions than mine here, which doesn't have that option until later, you certainly can't complete the Arc with only one subsequent Pause for input.]  If that's the case, then this part of the original:

 

(command "pLine" a b c ""); that last "" ends the Polyline, making the next line of code an Arc command, not a Polyline arc-segment option
(command "arc""END" PAUSE)

 

should be re-arranged:

 

(command "pLine" a b c "arc" "END" PAUSE "")

 

And the suggestion to just do it all inside a Polyline command, rather than ask for points first, should be:

 

(command "_.PLINE" PAUSE PAUSE PAUSE "_ARC" "_END" "")

 

[note the lack of period/decimal with Arc, since it's an option rather than a command name for which the period/decimal would be appropriate].

Kent Cooper, AIA
0 Likes
Message 7 of 9

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:

Another way is using the PLINE command directly:

....


I was thinking about suggesting that, but I can think of a reason they might prefer to do it with (getpoint) functions asking for points first.  Doing it within a PLINE command and with "raw" Pauses leaves it subject to the possibility that a User might choose to call for one of the options in the Pline prompt that would be there in front of them [width, arc, etc.], not perhaps knowing that their number of inputs is strictly limited.  Asking for the points first guarantees that the Polyline will be built starting with two straight segments, with the arc segment following to end it [if the interpretation in my previous Reply was correct], since Users will not have those other options presented to them.  The OP would need to decide what's preferable to them.

Kent Cooper, AIA
0 Likes
Message 8 of 9

scot-65
Advisor
Advisor
I'm thinking Kent is on the right tract with your inquiry.
I would suggest structuring your program to take advantage
of the Ortho switching and TEST user input before proceeding.

(setvar 'ORTHOMODE 1)
(setq a (getpoint...
(setq b (getpoint...
(setvar 'ORTHOMODE 0)
(if (and a b (setq c (getpoint...
(progn
[layermake, pline and arc goes here]
);progn
);if

I also see that running snaps are not suppressed.
This may be an issue when not very close.
Once past the user test of proper input, suppress OSMODE when drawing and restore when finished.

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 9 of 9

ВeekeeCZ
Consultant
Consultant

In my opinion it could be more automated... I see 3 scenarios

 

1st scenario (as Mleader behavior)
(setq pt1 (getpoint "Point arrow <exit>: "))
(setq pt2 (getpoint...
(setq pt3 (polar p2 0 dist)
(setq pt4 (polar p2 0 (* dist 2))
(command "_PLINE" pt3 pt2 pt1 "ARC" "SECOND" PAUSE PAUSE "")
(command "_TEXT" pt4 ... )


2st scenario (similar Mleader behavior)
same as 1st, but pick pt4 to allow user align the text.. and calculate pt2, pt3

(setq pt1 (getpoint "Point arrow <exit>: "))

(setq pt4 (getpoint...
(setq pt3 (polar p4 PI dist)
(setq pt2 (polar p4 PI (* dist 2))
(command "_PLINE" pt3 pt2 pt1 "ARC" "SECOND" PAUSE PAUSE "")
(command "_TEXT" pt4 )

 

3st scenario
add leader to existing text.
pre/select text (and get its point 10 as pt4)
(setq pt1 (getpoint "Point arrow: "))
calculate pt2 and pt3
(command "_PLINE" pt3 pt2 pt1 "ARC" "SECOND" PAUSE PAUSE "")

 

A question to the OP - Can be an arc loop somehow calculated? Is there some pattern? Or you prefer a user input...

0 Likes