Jump to content

Recommended Posts

Posted

Greetings,  I am writing a lisp routine that creates two plines between three points.  From left to right, pt1, pt3 and pt2.  The user selects pt1 and pt2 after which the program calculates pt3.  The input works fine.  The two pline commands each draw the correct pline when executed by themselves but not when both are in the program together.

 

The first line:  (command "_.pline" pt2 "a" "r" dist pt3 pt1 "")

The second line:  (command "_.pline" pt3 "a" "r" dist pt1 "")

 

When the routine executes the first pline it is correctly drawn but the second one is not drawn because of a "invalid" error.

The following is the echo for the second pline command:

Command: _.pline
Specify start point:
Current line-width is 0'-0"

Specify next point or [Arc/Halfwidth/Length/Undo/Width]: a
Specify endpoint of arc (hold Ctrl to switch direction) or
[Angle/CEnter/Direction/Halfwidth/Line/Radius/Second pt/Undo/Width]: r
Specify radius of arc: 0.765211554374230
Specify endpoint of arc (hold Ctrl to switch direction) or [Angle]: *Invalid*

 

I think the second command is trying, for some reason, to connect to the first one.  It seems I just have to completely get out of the first pline and start fresh with the second.  I thought having two separate command lines would do that but obviously does not.

 

How should I create these two plines?

 

Posted (edited)
2 hours ago, JerryFiedler said:

Greetings,  I am writing a lisp routine that creates two plines between three points.  From left to right, pt1, pt3 and pt2.  The user selects pt1 and pt2 after which the program calculates pt3.  The input works fine.  The two pline commands each draw the correct pline when executed by themselves but not when both are in the program together.

 

The first line:  (command "_.pline" pt2 "a" "r" dist pt3 pt1 "")

The second line:  (command "_.pline" pt3 "a" "r" dist pt1 "")

 

 

 

 

see this topic  

http://www.theswamp.org/index.php?topic=55931.0

http://www.lee-mac.com/bulgeconversion.html

 

perhaps Lee's (ppc-bulge pt1 pt2 cen) may help, just calculate cen

 

pt2->pt3, chord= 2r.sin(a1/2), where a1,angle= pt2~cen~pt3 

pt3->pt1, chord= 2r.sin(a2/2), where a2,angle= pt3~cen~pt1

 

mp to radius, L= r.cos(a/2) , where m is midpoint btwn pt2,pt3 with a1 or pt3,pt1 with a2

cen = polar mp A°±90° L , A=angle pt2->pt3 or pt3->pt1

(setq cen (polar mp (+ A (/ pi 2)) L) )

 

 

Edited by hanhphuc
extra link & formula
Posted

If the distance from pt1 to pt3 is greater than radius then crash. ie invalid

Posted

Thanks BigAl and hanhphuc for taking the time to respond to my post.  I have reconsidered my program since plines seem to be above my pay grade.  I have successfully accomplished what I wanted to do by using "arcs" instead of "plines".  I had to do the same mathematics for either command (such as end points, radii, etc) so the results are exactly the same graphically.  No problem; the math is not an issue.

The three arc commands are one right after the other in my lisp code with each command drawing one arc.

I still have my original question even though I am no longer using plines :

 

Each of the below command lines draw the correct pline without errors when executed by themselves.  But putting both commands, one right after the other, results in an error during execution of the second line.  The arc commands are independent of each other but these two plines seem to be interconnected somehow.

 

The first line:  (command "_.pline" pt2 "a" "r" dist pt3 pt1 "")

The second line:  (command "_.pline" pt3 "a" "r" dist pt1 "")

 

The question:  Why won't they execute one after the other?

Posted
12 hours ago, JerryFiedler said:

 

The first line:  (command "_.pline" pt2 "a" "r" dist pt3 pt1 "")

The second line:  (command "_.pline" pt3 "a" "r" dist pt1 "")

 

The question:  Why won't they execute one after the other?

 

i'm using Bricscad no error

 

osnap OFF?


(setq pt1 '(142 101)  pt2  '(151 105) pt3  '(144  105)  dist 10)

(progn
(command "_.pline" pt2 "a" "r" dist pt3 pt1 "")
(command "_.pline" pt3 "a" "r" dist pt1 "") 
(princ)
)
;;segment length > radii 
(setq pt1 '(139 88)  pt2  '(163 104) pt3  '(156  103)  dist 10)

 

Posted
16 hours ago, BIGAL said:

Did you read my post gave you the answer !!!

 

On 4/20/2020 at 5:11 PM, BIGAL said:

If the distance from pt1 to pt3 is greater than radius then crash. ie invalid

BigAl,

Thanks for your comments.  Yes, I read your post.  My routine draws plines with consistent geometry.  That is, the distance 1 to 3 is ALWAYS greater than the radius.  Sorry I did not respond to your post earlier.

Posted
8 hours ago, hanhphuc said:

 

i'm using Bricscad no error

 

osnap OFF?



(setq pt1 '(142 101)  pt2  '(151 105) pt3  '(144  105)  dist 10)

(progn
(command "_.pline" pt2 "a" "r" dist pt3 pt1 "")
(command "_.pline" pt3 "a" "r" dist pt1 "") 
(princ)
)
;;segment length > radii 
(setq pt1 '(139 88)  pt2  '(163 104) pt3  '(156  103)  dist 10)

 

hanhphuc,

Thank you very much for taking the time to test and prove that the commands work when used together.  I had already trashed my "pline" version of the routine since my "arc" version is working.  However, I just could not let this issue go unsolved (for me) so I recreated my "pline" routine this morning and lo and behold it works!!  I have no idea what was wrong with the earlier version.  Oh well, now I have two routines that do the same thing.  By the way this routine works with osnap OFF or set to my usual value.

Posted

I have had issues with code when typed into Notepad++ it appears to get some hidden characters, I had same problem retyped and then worked. It occurred a couple of times. Working ok at moment. 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...