Author Topic: Drawing a polyline (well it's more complicated than that)  (Read 5329 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Drawing a polyline (well it's more complicated than that)
« Reply #15 on: December 24, 2007, 02:51:21 PM »
Nothing wrong with that Gary.
I almost always prefer getdist over getreal and I would use this
Code: [Select]
(or a (setq a 0.0))just a personal preference.

Merry Christmas
Alan


Thanks Alan
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: Drawing a polyline (well it's more complicated than that)
« Reply #16 on: December 25, 2007, 12:33:56 PM »
Hi Gary,

Look at the getangle and getorient functions: as the getdist function, they allow to input the angle on the keyboard (according to current units) or with the cursor, and they return the angle in radians.

I'd rather write it like this

Code: [Select]
(defun c:DP (/ pt ofs ang ll lr ur ul)
  (if (setq pt (getpoint "\nPick point for center of rectangle *"))
    (progn
      (or (setq ofs (getdist pt "\nEnter offet value [offset 50]: "))
  (setq ofs 50.0)
      )
      (or (setq ang (getorient pt "\Enter angle [0 degrees]: "))
  (setq ang 0.0)
      )
      (setq ll (polar pt (- ang (* pi 0.75)) (sqrt (* (* ofs ofs) 2)))
    lr (polar pt (- ang (/ pi 4)) (sqrt (* (* ofs ofs) 2)))
    ur (polar pt (+ ang (/ pi 4)) (sqrt (* (* ofs ofs) 2)))
    ul (polar pt (+ ang (* pi 0.75)) (sqrt (* (* ofs ofs) 2)))
      )
      (makePline (list ll lr ur ul) 1 "LayerName")
    )
  )
  (princ)
)
« Last Edit: December 25, 2007, 12:39:56 PM by gile »
Speaking English as a French Frog

GDF

  • Water Moccasin
  • Posts: 2081
Re: Drawing a polyline (well it's more complicated than that)
« Reply #17 on: December 26, 2007, 10:28:31 AM »
Thanks Gile

I knew there had to be a better way.
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

iliekater

  • Guest
Re: Drawing a polyline (well it's more complicated than that)
« Reply #18 on: December 30, 2007, 06:09:42 AM »
Maybe it''s silly but what's the difference between getangle and getorient ?

hmspe

  • Bull Frog
  • Posts: 362
Re: Drawing a polyline (well it's more complicated than that)
« Reply #19 on: December 30, 2007, 08:37:49 AM »
Maybe it''s silly but what's the difference between getangle and getorient ?

getorient is always the angle measured from the positive X axis.  getangle is a relative angle.  Using a pi/2 value with getorient will always give a line lying along the positive Y axis.  Using a pi/2 value with getangle will give a line rotated 90 degrees clockwise from whatever the angle of the base object is.

The definitions are in Help under Contents/Customization Guide/AutoLISP, Visual LISP, and DXF.
"Science is the belief in the ignorance of experts." - Richard Feynman