Jump to content

Recommended Posts

Posted

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

Image.jpg

Posted (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 by BlackBox
Typo
Posted

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  "")

Posted

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)
)
   

Posted
(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)
)

Posted

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.

Posted

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

Posted
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

Posted

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

Posted
Could the lines to be trimed

 

What are you talking about ?

Posted
What are you talking about ?

I think your post is being hi-jacked!

Posted
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.

Posted

... to be a pain :lol:

 
(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?

Posted
... to be a pain :lol:

 
(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. 8)

(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> "")

Posted
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

Posted
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.

Posted (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 by asos2000
Posted
- 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 ?

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...