Author Topic: Lookin for a tracing routine.  (Read 1549 times)

0 Members and 1 Guest are viewing this topic.

PDJ

  • Guest
Lookin for a tracing routine.
« on: March 06, 2006, 07:14:15 PM »
OK, I've got this huge map of one of my villages and I just want to go in and trace over the outlines of the buildings.  Many, many moons ago I remember having a routine that would align my crosshairs with the first line I drew, thereby allowing all the other lines to be 90 degrees off that line.  I think it would allow me to keep goin and then close it when I was done. 

Does anyone have anything like that??  This is down and dirty, just need to trace some houses, no need for Cad overlay or traceit programs..

This Rectangle routine is similar to the one I'm looking for I think.

Code: [Select]
(defun c:rt ()
 (setq a (getvar "SNAPANG"))
 (setq b (getvar "ORTHOMODE"))
 (setq c (getvar "GRIDMODE"))
 (setq p1 (getpoint "\nFrom point: "))
 (setq p2 (getpoint p1 "\nTo point: "))
 (command "LINE" p1 p2 "")
 (setvar "SNAPANG" (angle p1 p2))
 (setvar "ORTHOMODE" 1)
 (setq p3(getpoint p2 "To point: "))
 (setq p4(polar p3 (angle p2 p1)
 (distance p2 p1)))
 (command "ERASE" "L" "")
 (command "PLINE" p1 p2 p3 p4 "CLOSE")
 (setvar "SNAPANG" a)
 (setvar "ORTHOMODE" b)
 (setvar "GRIDMODE" c)
(print)
(print)
(
   '((f x)(princ (vl-list->string (f x)))(princ))
   '((x)(mapcar '(lambda(x) (boole 6 42 x)) x))
   '(121 69 10 70 69 68 77 6 10 75 68 78 10 94
     66 75 68 65 89 10 76 69 88 10 75 70 70 10
     94 66 79 10 76 67 89 66 4 32
    )   
)
;(print "Hey, isn't that a polyrectangle??")
(princ)
)

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
Re: Lookin for a tracing routine.
« Reply #1 on: March 06, 2006, 08:59:36 PM »
Try this:

Code: [Select]
;|
 GOSNAP.lsp Set Snapangle according to various input
|;

(defun C:SA (/ DXF ANG @X @10 @11 11@ @50 @0 ZO ANS HS VS QS QA PT-A PT-B PT-BR PT-B1 PT-C PT-D PT-E)

  (defun DXF (Z L)
    (cdr (assoc Z L))
    );end defun DXF

  (defun RADTODEG (ANG)
    (/ (* ANG 180.0) pi)
    );end defun RADTODEG

  (defun DEGTORAD (ANG)
    (* ANG (/ pi 180.0))
    );end defun DEGTORAD

  (redraw)
  (setq ZO (entsel))
  (if (null ZO)
    (progn
      (initget "Increase Number View tWopt Zero")
      (setq ANS (getkword "\nSet SnapAng by  Increase Number View tWopt Zero: <0> "))
      (if (= nil ANS)
(setq ANS "Zero")
);end if

      (cond
((= ANS "Increase")
(setq ANG (+ (getvar "Snapang") (DEGTORAD (getreal "\rEnter angle to increase by: "))))
)
((= ANS "Number")
(setq ANG (DEGTORAD (getreal "\rEnter angle for crosshairs: ")))
)
((= ANS "View")
(setq ANG (* -1 (getvar "viewtwist")))
)
((= ANS "tWopt")
(setq PT-A (getpoint "\nSelect 1st Point ") PT-B (getpoint PT-A "\nSelect 2nd Point ") ANG (angle PT-A PT-B))
)
((= ANS "Zero")
(setq ANG 0.0)
)
);end cond

      (setvar "SNAPANG" ANG)
      );end progn

    (progn
      (setq @X (entget (car ZO)) ANS (DXF 0 @X) @50 (DXF 50 @X) @10 (DXF 10 @X) @11 (DXF 11 @X) 11@ (cadr (DXF 11 @x)))
      (cond
((= ANS "LINE")
(setq ANG (angle @10 @11))
)
((= ANS "INSERT")
(setq ANG @50)
)
((= ANS "TEXT")
(setq ANG @50)
)
((= ANS "DIMENSION")
(setq ANG @50)
)
((= ANS "MTEXT")
(setq ANG (atan (/ 11@ (sqrt (- 1.0 (* 11@ 11@ ))))))
)
((or (= ANS "POLYLINE") (= ANS "LWPOLYLINE"))
(setq QA (osnap (cadr ZO) "nea") @X (entget (entnext (DXF -1 @X))) PT-A (DXF 10 @X) ANG nil)
(while
   (null ANG)
   (setq @X (entget (entnext (DXF -1 @X))) PT-B (DXF 10 @X))
   (setq ANG (if (equal (angle PT-A PT-B) (angle PT-A QA) 0.01) (min (angle PT-A PT-B) (angle PT-B PT-A)) nil) PT-A PT-B)
   );end while
); pline
((or (= ANS "CIRCLE") (= ANS "ARC"))
(setq QA (osnap (cadr ZO) "nea") ANG (angle @10 QA) ANG (if (>= ANG (/ pi 2)) (- ANG (/ pi 2)) (+ ANG (/ pi 2))))
)
);end cond
      (setvar "SNAPANG" ANG)
      );end progn
    );end if
  (princ)
  );end defun C:SA

(Prompt "\n{1.0}SnapAngle                     SA ")
(princ)

Let me know how it works out for you. I think this might be what you are looking for.

Increase: Asks for a numeric value to increase the SnapAngle by.
Number: Asks for an exact angle.
View: Changes SnapAngle to by parallel to current view.
tWopt: Changes SnapAngle based on two (2) picked points.
Zero: <Default> Sets SnapAngle to 0
« Last Edit: March 06, 2006, 09:12:48 PM by Slim »
I drink beer and I know things....

Dent Cermak

  • Guest
Re: Lookin for a tracing routine.
« Reply #2 on: March 06, 2006, 10:13:27 PM »
Is what you are lookinf for is the ability to draw a line perpendicular FROM any point on a previous line? If so, I have that lisp. I think it's in my folder on the Lilly Pond. "PERPL.LSP"

OK, I lied. It ain't there, so here it is:



(Defun C:PERPL (/ SA SB SNP OM OS PT1 PT2)
   (setvar "cmdecho" 0)
   (setq
     SA (getvar "snapang")
     SB (getvar "snapbase")
    SNP (getvar "snapmode")
     OM (getvar "orthomode")
     OS (getvar "osmode")
    PT1 (osnap (getpoint
        "\nPick point on line to draw perpendicular from: "
      )
      "nea"
     )
   )
   (setvar "osmode" 0)
   (setq PT2 (osnap PT1 "end"))
   (if (equal PT1 PT2)
     (setq PT2 (osnap PT1 "MID"))
   )
   (command ".snap" "r" PT1 PT2)
   (setvar "snapmode" 0)
   (setvar "orthomode" 1)
   (prompt "\nto point:")
   (command ".line" PT1 pause "")
   (setvar "snapang" SA)
   (setvar "snapbase" SB)
   (setvar "snapmode" SNP)
   (setvar "orthomode" OM)
   (setvar "osmode" OS)
   (setvar "cmdecho" 1)
   (princ)
); end perpl.lsp
 


« Last Edit: March 06, 2006, 10:19:34 PM by Dent Cermak »

Kate M

  • Guest
Re: Lookin for a tracing routine.
« Reply #3 on: March 07, 2006, 12:15:45 PM »
Tools-->Drafting Settings-->Polar Tracking-->Polar Angle measurement="Relative to last segment"

?

PDJ

  • Guest
Re: Lookin for a tracing routine.
« Reply #4 on: March 07, 2006, 12:21:49 PM »
VERY nice Kate.. Good find.. I never even tried that option..

Thanks to Dent and Slim too, I'ma look at your routines at a later date..


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Lookin for a tracing routine.
« Reply #5 on: March 08, 2006, 11:43:55 AM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

pmvliet

  • Guest
Re: Lookin for a tracing routine.
« Reply #6 on: March 08, 2006, 02:19:01 PM »
Are the houses already drawn? Are they in a reference file and you need them active?
If the answer is yes to both questions:
You could use Nested copy if you have the bonus tools.
Or you can use bpoly to create a closed pline

Pieter