Author Topic: rectangle draw  (Read 1398 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 286
rectangle draw
« on: May 18, 2008, 03:19:26 AM »
hello friend ~ 
i am have difficultiy in simple lisp code .
that is    rectangle  draw routine   regardeless ucs.
if i select  pt1 and pt2  ,  ucs changed  and  draw  rectangle  which based  on pt1 and pt2 point.
but that routine don't work well
what problem ?


(defun C:ar1 ( / obj pt1 pt2 pt11 pt22 pt33 rec-temp )
   
   (setvar "osmode" 35 )
   (setvar "cmdecho" 0 )
   (command "ucs" "w")
   (command "ucs" "x" "90" )
    (setq pt1 (GETPOINT "\n first  : ")  )
   (setq pt2 (GETPOINT "\n second : ")   )
   
   (setq pt4-temp  (polar pt1 (dtr 90) 50  )    )
   
   (setvar "osmode" 0 )
   (vl-cmdf "_.UCS" "_3" pt1 pt2  pt4-temp)
    (setq pt3  (polar pt2 (dtr 90  )  500    )      )
   (command "rectangle" pt1 pt3 "")   

         

)


gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: rectangle draw
« Reply #1 on: May 18, 2008, 06:18:07 AM »
Hi,

As far as I understand what you want to do, The problem is that pt1 and pt2 coordinates are defined in your first UCS and the rectangle is drawn in the second one.
If you want to use pt1 and pt2 to draw the rectangle, their coordinates have to be translanted in this UCS.
A way to do this is to to translate pt1 and pt2 UCS coordinates to WCS coordinates, then, after UCS have been changed translate them to the new UCS.

Code: [Select]
(defun C:ar1 (/ obj pt1 pt2 pt11 pt22 pt4-temp pt3)

  (setvar "osmode" 35)
  (setvar "cmdecho" 0)
  (command "_.ucs" "_w")
  (command "_.ucs" "x" "90")
  (setq pt1 (getpoint "\n first  : "))
  (setq pt2 (getpoint pt1 "\n second : "))

  ;; Translate points from current UCS to WCS
  (setq pt11 (trans pt1 1 0))
  (setq pt22 (trans pt2 1 0))

  (setq pt4-temp (polar pt1 (/ pi 2) 50))

  (setvar "osmode" 0)
  (vl-cmdf "_.UCS" "_3" pt1 pt2 pt4-temp)

  ;; Translate points from WCS to the new current UCS
  (setq pt1 (trans pt11 0 1))
  (setq pt2 (trans pt22 0 1))
 
  (setq pt3 (polar pt2 (/ pi 2) 500))
  (command "rectangle" pt1 pt3)
)
Speaking English as a French Frog

dussla

  • Bull Frog
  • Posts: 286
Re: rectangle draw
« Reply #2 on: May 18, 2008, 08:20:31 AM »
thank you gile ~
that is perpect
always thank you

i wonder  you didn't see for a long time
were you busy ?
 :-) :-) :-) :-) :-)

at any way ~  thank you , thank you