Author Topic: New Line command  (Read 1972 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
New Line command
« on: April 22, 2011, 11:13:55 AM »
This is a very simple lisp and hardly worth sharing but I thought someone may be doing the same
process as I occasionally do. The contractor gives me a drawing in a picture format & asked to
have the drawing recreated. Most are concrete block homes here in Florida so keeping the dimensions
in block modules is important for cost reasons. I scale the picture to a known dimension and then
proceed to trace the exterior walls. But to keep them in 4 inch modules I use this lisp instead of
the normal LINE command.
<edit: added angle corrections for angles near 45 deg modules>
Code: [Select]
;;; FUNCTION
;;; Draw a line with a length rounded off with a fuzz factor
;;;  Setting LineFuzz to 4 will keep line length to a multiple of 4
;;;  which works well for concrete block walls
;;;
;;; ARGUMENTS
;;; none
;;;
;;; USAGE
;;; LineX
;;;
;;; PLATFORMS
;;; 2000+ [tested in ACAD2006 only]
;;;
;;; AUTHOR
;;; Copyright© 2011 Charles Alan Butler
;;; TheSwamp.org
;;;
;;; VERSION
;;; 1.1 Apr 15, 2011
;;;
;;; YOU MAY USE THIS CODE ONLY FOR *NON-COMMERCIAL*
;;; PURPOSES AND ONLY IF YOU RETAIN
;;; THIS HEADER COMPLETE AND UNALTERED
;;; YOU MUST CONTACT ME IF YOU WANT TO USE IT COMMERCIALLY

(defun c:linex (/ p1 p2 dist ang ents pts linefuzz angfuzz)
  (setq linefuzz 4.0)                   ; 4" block modules
  (setq angfuzz 0.001)

  ;;  by CAB 03/22/2009
  ;;  Expects pts to be a list of 2D or 3D points
  ;;  Returns new pline object
  (defun makepline (spc pts / norm elv pline)
    (setq norm (trans '(0 0 1) 1 0 t)
          elv  (caddr (trans (car pts) 1 norm))
    )
    (setq pline
           (vlax-invoke
             spc
             'addlightweightpolyline
             (apply 'append
                    (mapcar '(lambda (pt)
                               (setq pt (trans pt 1 norm))
                               (list (car pt) (cadr pt))
                             )
                            pts
                    )
             )
           )
    )
    (vla-put-elevation pline elv)
    (vla-put-normal pline (vlax-3d-point norm))
    pline
  )


  (setq 45deg (/ pi 4))                 ; round off if mod of 45 deg
  (setq p1 (getpoint "\n_line Specify first point: "))
  (while (and p1 (setq p2 (getpoint p1 "\nSpecify next point or [Undo]:")))
    (setq dist (distance p1 p2)
          ang  (angle p1 p2)
    )
    (setq dist (* (fix (+ (/ dist linefuzz) 0.99)) linefuzz)) ; distance correction
    (if (< (rem ang 45deg) 0.0523599)   ; +- 3 deg
      (setq ang (* 45deg (fix (/ ang 45deg))))
      (princ (strcat "\nWarning: Segment " (itoa (max (length pts) 1))" is a non standard angle."))
    )

    (setq p2 (polar p1 ang dist))
    (setq ents (cons
                 (entmakex
                   (list (cons 0 "LINE")
                         (cons 6 "BYLAYER")
                         ;;(cons 8 "0")
                         (cons 10 p1)
                         (cons 11 p2)
                         (cons 39 0.0)
                         (cons 62 256)
                   )
                 )
                 ents
               )
          pts  (if pts (cons p2 pts) (list p2 p1))
    )
    (setq p1 p2)
  )
  (and pts
       (null (initget "Yes No"))
       (/= (getkword "\nConvert to a Polyline [Yes/No] <Yes>: ") "No")
       (makepline
         (if (= 1 (getvar "CVPORT"))
           (vla-get-paperspace (vla-get-activedocument (vlax-get-acad-object)))
           (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
         )
         pts
       )
       (mapcar 'entdel ents)
  )
  (princ)
)
« Last Edit: April 22, 2011, 12:29:28 PM by CAB »
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.

danallen

  • Guest
Re: New Line command
« Reply #1 on: April 22, 2011, 01:05:47 PM »
Interesting. I assumed the grid would be relative to origin, but it varies based on the start point. Are the homes not on an overall grid layout, or does each contiguous wall segment vary? Did you consider drawing a faintly colored 4" square hatch and just snapping to intersections?

Thanks for sharing,

Dan

jbuzbee

  • Swamp Rat
  • Posts: 851
Re: New Line command
« Reply #2 on: April 22, 2011, 02:02:28 PM »
CAB, nice.  I do something similar (the image thing) But I use an AEC Ceiling Grid to make sure i stick with CMU dimensions.

Hey, when are we gonna have a cuban in Ybor?

Oh, and BTW do you know how to install a brake light switch??

http://www.theswamp.org/index.php?topic=38026.0
James Buzbee
Windows 8

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: New Line command
« Reply #3 on: April 22, 2011, 02:10:03 PM »
Well I don't know why I resist using the grid but I have avoided it.
Always using ortho on and snaps to keep me on the straight & narrow.
Perhaps it's time to change my ways.
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.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: New Line command
« Reply #4 on: April 22, 2011, 02:19:48 PM »
I use snaps and ortho simply because I can't conceive how a grid would work in an architectural situation .. I mean seriously, how can you set a grid when everything is different sizes ...

I think your solution is cool ... I used a similar idea some years ago when I was doing primarily foundation work where CMU's were being used.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie