Hello there,
I wrote the following lsp to make a grid of vertical lines and bounding box with an input stp.
My problem is the lines not in correct position,lthough I printed point coordinates p3, p4 to make sure calculations are correct. they appear to be so.
here is my lsp. Any help??
thank you
;------------------------------------------
(defun hpromptr (textq default_value)
(setq tmp (getreal ( strcat "\n" textq "[" (rtos default_value) "]" )))
(if (= tmp nil) (setq tmp default_value))
(setq tmp tmp)
)
;-------------------------------------------
;-------------------------------------------
;-------------------------------------------
;-------------------------------------------
(defun c:ooo(/ i nw xd stp p1 p2 p3 p4 w width
x1 y1 x2 y2 pp)
; (hinit)
; (hlayer "_Grid")
(setq stp (hpromptr "Step:" 100.0 ))
(setq w (hpromptr "Fram Width:" 0.1))
(setq p1 (getpoint "\nPick first point: "))
(setq p2 (getcorner p1 "\nPick second point: "))
(command "rectang" "w" w p1 p2)
(command "rectang" "w" w p1 p2)
(setq width (- (car p2) (car p1)))
(setq nw (fix (/ width stp)))
(p nw)
(setq xd (car p1))
(setq i 0)
(setq y1 (cadr p1))
(setq y2 (cadr p2))
(repeat nw
(setq pp (+ xd stp))
(setq xd pp)
(setq p3 (list pp y1 0.0))
(setq p4 (list pp y2 0.0))
(command "line" p3 p4 "")
)
; (hprev_layer)
; (hend)
)
Solved! Go to Solution.
Solved by dbhunia. Go to Solution.
Try this
;------------------------------------------ (defun hpromptr (textq default_value / tmp) (initget 6) (setq tmp (cond ( (getreal (strcat "\n" textq " <" (rtos default_value) "> : "))) (default_value))) ) ;------------------------------------------- ;------------------------------------------- ;------------------------------------------- ;------------------------------------------- (defun c:ooo(/ osm stp w p1 p2 nw xd y1 y2 p3 p4) ; (hinit) ; (hlayer "_Grid") (cond ( (/= (getvar 'osmode) 0) (setq osm (getvar 'osmode)) (setvar 'osmode 0))) (setq stp (hpromptr "Step" 100.0 )) (setq w (hpromptr "Frame Width" 0.1)) (setq p1 (getpoint "\nPick first point: ")) (setq p2 (getcorner p1 "\nPick second point: ")) ;(command "rectang" "w" w p1 p2) (command "rectang" "w" w p1 p2) (setq nw (fix (/ (- (car p2) (car p1)) stp))) ;(p nw) (setq xd (car p1)) (setq y1 (cadr p1)) (setq y2 (cadr p2)) (repeat nw (setq xd (+ xd stp)) (setq p3 (list xd y1 0.0)) (setq p4 (list xd y2 0.0)) (command "line" p3 p4 "") ) (if osm (setvar 'osmode osm)) ; (hprev_layer) ; (hend) )
I am not one of the robots you're looking for
You can also try by this change only (without manipulating "OSMODE").......
(command "line" "_none" p3 "_none" p4 "")
@hseeda hi,
follow the good advises you got here but if you want to upgrade it a little more, make it support draw the rectangle from any direction meaning from upper right corner down to bottom left (and any other direction) this may easily implemented with (polar) function to calculate the points accordingly.
moshe
Thanks for the reply. Alot of ideas can be implemented, but I was buzzled by the missalignment. NOw I figure out its the osnap settings.
Can't find what you're looking for? Ask the community or share your knowledge.