PDA

View Full Version : Traverse Routine



CADISLIFE
2017-09-12, 02:30 AM
Hi all,

I've been searching for a traverse tool that allows the user to select an endpoint of a line, choose another point along the same line as a backsite, then have the user enter an angle and distance and have a line drawn at the given distance and angle from the original referenced line. I've found many bearing and distance traverse tools but no luck finding one as described. Please advise if my description isn't clear enough.

Thanks,

Bruno.Valsecchi
2017-09-12, 09:29 PM
Hi,

Try this! Can be a starting for you.


(defun c:relative_angle ( / js oldsnap oldortho dxf_ent alpha ang_supp)
(princ "\nSelection of reference line.")
(setq js (ssget "_+.:E:S" '((0 . "LINE"))))
(cond
(js
(setq
oldsnap (getvar "snapang")
oldortho (getvar "orthomode")
dxf_ent (entget (ssname js 0))
alpha (angle (trans (cdr (assoc 10 dxf_ent)) 0 1) (trans (cdr (assoc 11 dxf_ent)) 0 1))
)
(initget 1)
(setq ang_supp (getangle "\nAngle to add: "))
(setvar "snapang" (+ alpha ang_supp))
(setvar "orthomode" 1)
(command "_.line" pause "_none" pause "")
(setvar "orthomode" oldortho)
(setvar "snapang" oldsnap)
(command "_.line" "")
)
)
(princ)
)

CADISLIFE
2017-09-12, 10:51 PM
Thanks, I'll give it a try. I have a feeling I'm going to be in over my head with this one though, thanks for the help nonetheless!

BIG-AL
2017-09-22, 08:23 AM
Be careful of using assoc 10 & 11 these are hard set by the direction the line was drawn so angle could be 180 out. A suggestion is pick line point near end then compare the ends to this point and possibly swap the angle direction, also much easier than having to pick two points.



(setq d1 (distance pt1 pt3))
(setq d2 (distance pt2 pt3))
(if (> d1 d2)
(progn
(setq temp pt1)
(setq pt1 pt2)
(setq pt2 temp)
)
)
(setq ang (angle pt1 pt2)) ; this is the angle towards the pick point