Michaels Posted November 21, 2010 Posted November 21, 2010 Hello , Hope that someone could guid me how to get these points ( p1, p2, p3, p4 ) as shown in the attached image in parrallel with the start and end points that representing the center line of the rectangle . So here is my start ...... (setq wid (getdist "\n Width of Rectangle :" )) (setq Start (getpoint "\n Specify Center point of Duct :")) (setq End (getpoint "\n Specify Center point of Duct :" Start)) Wid argument means the offset distance on the two sides of the rectangle Regards, Michaels Quote
BlackBox Posted November 21, 2010 Posted November 21, 2010 (edited) Use the polar function to calculate the points perpendicular to both your start and end points. For the angle calculations use the angle from start to end adding half pi, and negative half pi, to yield the resultant angles needed. Hope this helps! Edited November 21, 2010 by BlackBox Typo Quote
Small Fish Posted November 21, 2010 Posted November 21, 2010 Maybe something like this....... (setq OffDist (getreal "\nOffset Distance...: ")) PtA (getpoint "\nPick point 1: ") PtB (getpoint PtA "\nPick point 2: ") PtAng (angle PtA PtB) Pt1 (polar PtA (+ PtAng (* 0.5 pi)) OffDist) Pt2 (polar PtA (- PtAng (* 0.5 pi)) OffDist ) Pt3 (polar PtB (+ PtAng (* 0.5 pi)) OffDist) Pt4 (polar PtB (- PtAng (* 0.5 pi)) OffDist ) );setq (command "pline" pt1 Pt3 "") (command "pline" Pt2 pt4 "") Quote
Lee Mac Posted November 21, 2010 Posted November 21, 2010 Pretty pointless, but fun to write (defun c:test ( / w p g a q l ) (if (and (setq w (getdist "\nSpecify Width: ")) (setq w (/ w 2.) p (getpoint "\nSpecify First Point: ")) (while (= 5 (car (setq g (grread 't 13 0)))) (redraw) (setq a (angle p (setq q (cadr g)))) (grvecs (setq l (list 256 (polar p (+ a (/ pi 2.)) w) (polar q (+ a (/ pi 2.)) w) (polar p (- a (/ pi 2.)) w) (polar q (- a (/ pi 2.)) w) ) ) ) l ) ) (mapcar (function (lambda ( p q ) (entmakex (list (cons 0 "LINE") (cons 10 (trans p 1 0)) (cons 11 (trans q 1 0)))) ) ) (list (cadr l) (cadddr l)) (list (caddr l) (car (cddddr l))) ) ) (redraw) (princ) ) Quote
Lt Dan's legs Posted November 22, 2010 Posted November 22, 2010 (defun c:test (/ p1 p2 of) (setq p1 (getpoint "\nSpecify first point: ") p2 (getpoint p1 "\nSpecify second point: ") of (getint "\nSpecify offset distance: ")) (entmake (list (cons 0 "line") (cons 10 (polar p1 (+ (angle p1 p2)(angtof "270.000000")) of)) (cons 11 (polar p2 (+ (angle p1 p2)(angtof "270.000000")) of)) ) ) (entmake (list (cons 0 "line") (cons 10 (polar p1 (+ (angle p1 p2)(angtof "90.000000")) of)) (cons 11 (polar p2 (+ (angle p1 p2)(angtof "90.000000")) of)) ) ) (princ) ) Quote
Michaels Posted November 22, 2010 Author Posted November 22, 2010 Thank you all guys , I do appreciate your help a lot. I did it after posting for help , and it seems completely different than the others codes. So is it OK , or I have to change any of it ? (setq wid (getdist "\n Width of Distance :")) (setq c1 (getpoint "\n Specify Center point 1 :")) (setq c2 (getpoint "\n Specify Center point 2 :" c1)) (setq ang (angle c1 c2)) (setq p1 (polar c1 (+ pi (/ pi 2) ang) (/ wid 2))) (setq p2 (polar p1 ang (distance c1 c2))) (setq p3 (polar c1 (+ (/ pi 2) ang)(/ wid 2))) (setq p4 (polar p3 ang (distance c1 c2))) Many thanks. Quote
Small Fish Posted November 22, 2010 Posted November 22, 2010 That looks fine....there are many ways to skin a cat. Don't forget to set osmode to zero while the code runs, otherwise errors could occur. SF Quote
Lee Mac Posted November 22, 2010 Posted November 22, 2010 Don't forget to set osmode to zero while the code runs, otherwise errors could occur. To be honest, I would avoid the command call altogether - entmake'ing objects like Lines/LWPolylines is quite easy to learn and not only is it 10x faster than command calling, it also avoids problems with OSMODE hence also avoiding the need for a dedicated error handler (to reset System Variables) in most cases. Lee Quote
Michaels Posted November 22, 2010 Author Posted November 22, 2010 Thank a lot Small Fish for your interests , and I do appreciate your replies . Thanks Lee , I agree with you for the entmak'ing is much better than any command in a Lisp, and I doing my best to avoid using Command instead od Entmakes Functions . Besides that , it would give me the experience of learning more ways in dealing with Lisp in general. Thank a lot. Michaels Quote
Michaels Posted November 23, 2010 Author Posted November 23, 2010 Could the lines to be trimed What are you talking about ? Quote
Small Fish Posted November 23, 2010 Posted November 23, 2010 What are you talking about ? I think your post is being hi-jacked! Quote
Small Fish Posted November 23, 2010 Posted November 23, 2010 To be honest, I would avoid the command call altogether .... I don't see anything wrong with command call method (rather than entmake) sure it's faster but Michaels has only two entities, even with a dozen entities to produce, visually you would not any difference. The number of lines to code I reckon would also be about equal. However I agree when making large quantities of entities entmake is better. Quote
Lt Dan's legs Posted November 23, 2010 Posted November 23, 2010 ... to be a pain (defun c:test (/ make_line p1 p2 of) (defun make_line (ang offset) (entmake (list (cons 0 "line") (cons 10 (polar p1 (+ (angle p1 p2) ang)(* offset 0.5))) (cons 11 (polar p2 (+ (angle p1 p2) ang)(* offset 0.5))) ) ) ) (setq p1 (getpoint "\nSpecify first point: ") p2 (getpoint p1 "\nSpecify second point: ") of (getdist "\nSpecify offset distance: ")) (make_line (angtof "270.000000") of) (make_line (angtof "90.000000") of) (princ) ) Forgive me if I'm wrong but, couldn't there be a osnaps problem with a command call when selecting close to another object? Quote
alanjt Posted November 23, 2010 Posted November 23, 2010 ... to be a pain (defun c:test (/ make_line p1 p2 of) (defun make_line (ang offset) (entmake (list (cons 0 "line") (cons 10 (polar p1 (+ (angle p1 p2) ang)(* offset 0.5))) (cons 11 (polar p2 (+ (angle p1 p2) ang)(* offset 0.5))) ) ) ) (setq p1 (getpoint "\nSpecify first point: ") p2 (getpoint p1 "\nSpecify second point: ") of (getdist "\nSpecify offset distance: ")) (make_line (angtof "270.000000") of) (make_line (angtof "90.000000") of) (princ) ) Forgive me if I'm wrong but' date=' couldn't there be a osnaps problem with a command call when selecting close to another object?[/quote']Just to be a pain. (mapcar (function make_line) (list (* 1.5 pi) (/ pi 2.)) (list of of)) Yes, running OSnaps will give fits to a command call that refers to a point. However, this can be avoided by issuing the osnap override "_non" or "_none" before imputing the point. One could also temporarily turn off running osnaps or just entmake vla-add* it. eg. (command "_.line" "_non" <Point> "_non" <Point> "") Quote
Michaels Posted November 23, 2010 Author Posted November 23, 2010 I think your post is being hi-jacked! I am sorry, I didn't understand the meaning of (hi-jacked) . So what does it mean ? Thanks Quote
Small Fish Posted November 23, 2010 Posted November 23, 2010 I am sorry, I didn't understand the meaning of (hi-jacked) . So what does it mean ? - Another poster is taking over your original question by asking something that is irrelevant to your post - rather than starting a new thread. Quote
asos2000 Posted November 24, 2010 Posted November 24, 2010 (edited) What are you talking about ? The lisp draw 2 lines. Could the lisp trim the 2 lines (if there a line) after creating the new 2 lines Edited November 24, 2010 by asos2000 Quote
Michaels Posted November 24, 2010 Author Posted November 24, 2010 - Another poster is taking over your original question by asking something that is irrelevant to your post - rather than starting a new thread. I am the thread writter, and your words should be directed to the asos2000 since that he/she wrote something unclear and mysterious . understand ? Quote
Recommended Posts
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.