Author Topic: Help with extending  (Read 3230 times)

0 Members and 1 Guest are viewing this topic.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Help with extending
« on: February 04, 2004, 01:04:40 PM »
This routine draws our elevation lines (grade, top of foundation, first & second floor & ceiling lines, first & second fascias).

I want to extend the grade, floor & ceiling lines 2'-0" each way after created.
Also, extend the fascia lines 1'-0" each way and create a vertical line on each side to close them-----v

    ------------------------------------------
          ___________________________
         |___________________________|


    -----------------------------------------

    -----------------------------------------

          ___________________________
         |___________________________|



     ------------------------------------------

          ___________________________
     ___________________________________


Sorta what it would look like...also, what's an easy way to create the layers it will change them to if they're not already created?

I know this is a bunch of stuff, but I'm trying to learn, and seeing the way others do it is so much easier to understand and breakdown than reading tutorials is.  I hijacked some formatting from other posts to spruce mine up, and make it more legible.  Spank you very much for any help.  :twisted:

Code: [Select]

;;             ElevationLines.lsp
;;         Created by Dominic Cesare

;;                 01/23/2004

;;======================
;;    Start of Routine
;;======================

(defun c:ELEVATIONLINES()


;;; -------  Getting Floor Heights   ------------------

(setq HT1 (getdist "\nEnter First Floor Height : "))

(setq HT2 (getdist "\nEnter Second Floor Height : "))



;;; -------  Getting Variable First Floor Construction Height   ------------------

(setq FC1 (getdist "\nEnter First Floor Construction Height : "))



;;; -------  Setting Up & Down for offsetting   ------------------

(setq DN '(0 -100000000)
UP '(0 100000000)
)



;;; -------  Creating Grade & Top of Foundation   ------------------

;creating grade line
(command "line" pause pause "")

;setting grade line to L1
(setq L1 (entlast))

;changing grade line to layer wall, color white
(command "change" L1 "" "P" "LA" "WALL" "C" "WHITE" "")

;creating top of foundation line
(command "offset" "8.0" L1 UP "")

;setting top of foundation line to FDN
(setq FDN (entlast))

;changing top of foundation line to layer wall, color 15
(command "change" FDN "" "P" "LA" "WALL" "C" "15" "")



;;; -------  Creating First Floor Lines   ------------------

;creating first floorline
(command "offset" FC1 FDN UP "")

;setting first floorline to FLR1
(setq FLR1 (entlast))

;changing first floorline to layer FLR, color bylayer
(command "change" FLR1 "" "P" "LA" "FLR" "C" "BYLAYER" "")

;creating first floor ceilingline
(command "offset" HT1 FLR1 UP "")

;setting first floor ceilingline to CLG1
(setq CLG1 (entlast))

;changing first floor ceilingline to layer CLG
(command "change" CLG1 "" "P" "LA" "CLG" "")



;;; -------  Creating First Floor Fascia   ------------------

;creating top of first floor fascia
(command "offset" "3.0" CLG1 DN "")

;setting top of first floor fascia to F1T
(setq F1T (entlast))

;changing top of first floor fascia to layer WALL
(command "change" F1T "" "P" "LA" "WALL" "")

;creating bottom of first floor fascia
(command "offset" "8.0" F1T DN "")

;setting bottom of first floor fascia to F1B
(setq F1B (entlast))



;;; -------  Creating Second Floor Lines   ------------------

;creating second floorline
(command "offset" "10.0" CLG1 UP "")

;setting second floorline to FLR2
(setq FLR2 (entlast))

;changing second floorline to layer FLR
(command "change" FLR2 "" "P" "LA" "FLR" "")

;creating second floor ceilingline
(command "offset" HT2 FLR2 UP "")

;setting second floor ceilingline to CLG2
(setq CLG2 (entlast))

;changing second floor ceilingline to layer CLG
(command "change" CLG2 "" "P" "LA" "CLG" "")



;;; -------  Creating Second Floor Fascia   ------------------

;creating top of second floor fascia
(command "offset" "3.0" CLG2 DN "")

;setting top of second floor fascia to F2T
(setq F2T (entlast))

;changing top of second floor fascia to layer WALL
(command "change" F2T "" "P" "LA" "WALL" "")

;creating bottom of second floor fascia
(command "offset" "8.0" F2T DN "")

;setting top of second floor fascia to F2B
(setq F2B (entlast))


(princ)

)
(princ)


;;======================
;;    End of Routine
;;======================

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Help with extending
« Reply #1 on: February 04, 2004, 09:05:24 PM »
Dommy,

I remember you post at the other site (AutoDesk).

Glad to see you here.. :)

There are many ways to approach this routine but I did not
see an easy way to extend the lines, so I rewrote it using
points and a subroutine to get the job done.
The routine I have done feels clumsy to me but I couldn't
come up with a better approach without spending more time.
Perhaps someone here can come up with an elegant solution.

CAB


Code: [Select]
(defun c:elevationlines ()
  ;;;  Local Functions

  ;;;  newline creates a new line
        ;; newlinw     color extend

  (defun newline (dst  ;; offset distance from last line
                  dir  ;; direction to offset from last line
                  lay  ;; layer name to make new line
                  col  ;; color to make new line
                  ext  ;; exten distance to add to each end
                  )
    (setq p1 (polar p1 dir dst);; new start & end points
          p2 (polar p2 dir dst)
    )
    (if (/= ext 0) ;; change width of lines
      (setq p1 (polar p1 right ext) ;; new start & end points
            p2 (polar p2 left ext)
      )
    )
    (command ".line" p1 p2 "");; Draw the line
    (if col ;; change the layer of the new line
      (command ".change" (entlast) "" "P" "LA" lay "C" col "")
      (command ".change" (entlast) "" "P" "LA" lay "C" "BYLAYER" "")
    )
  )

  ;;;  Draw two vertical lines 8" up from last p1 p2
  (defun facia_ends ()
    (command ".line" p1 (polar p1 up 8) "")
    (command ".change" (entlast) "" "P" "LA" "WALL" "C" "BYLAYER" "")
    (command ".line" p2 (polar p2 up 8) "")
    (command ".change" (entlast) "" "P" "LA" "WALL" "C" "BYLAYER" "")
  )

  ;;;////////////////////
  ;;;  Start of Routine
  ;;;\\\\\\\\\\\\\\\\\\\\
  (setvar "Cmdecho" 0)

  ;;; Create layers if they dont exist in this drawing
  (if (not(tblsearch "LAYER" "WALL"))
    (command "-layer" "M" "WALL" "C" "WHITE" "" "")
  )
  (if (not(tblsearch "LAYER" "FLR"))
    (command "-layer" "M" "FLR" "C" "WHITE" "" "")
  )
  (if (not(tblsearch "LAYER" "CLG"))
    (command "-layer" "M" "CLG" "C" "WHITE" "" "")
  )
         

;;; -------  Getting Floor Heights   ------------------
  (setq ht1 (getdist "\nEnter First Floor Height : "))
  (setq ht2 (getdist "\nEnter Second Floor Height : "))

;;; -------  Getting Variable First Floor Construction Height   ------------------
  (setq fc1 (getdist "\nEnter First Floor Construction Height : "))

;;; -------  Setting Up & Down for offsetting   ------------------
  (setq dn    (* pi 1.5)
        up    (* pi 0.5)
        right 0
        left  pi
  )

;;; -------  Creating Grade & Top of Foundation   ------------------

  ;;creating grade line
  (if (setq p1 (getpoint "\nPick start point of line."))
    (if (setq p2 (getpoint p1 "\nPick end point of line."))
      (progn
        (setvar "Osmode" 0)
        (setq oldsnap (getvar "Osmode")
             oldecho (getvar "Cmdecho")
         );setq

        (command ".undo" "begin")
        ;; creating grade line
        (newline 0 up "WALL" "WHITE" 24)

        ;;creating top of foundation line
        (newline 8 up "WALL" "15" -24)


;;; -------  Creating First Floor Lines   ------------------
        ;;creating first floorline
        (newline fc1 up "FLR" "BYLAYER" 24)

        ;;creating first floor ceilingline
        (newline ht1 up "CLG" nil 0)

;;; -------  Creating First Floor Fascia   ------------------
        ;;creating top of first floor fascia
        (newline 3 dn "WALL" nil -12)

        ;;creating bottom of first floor fascia
        (newline 8 dn "WALL" nil 0)
        (facia_ends)

;;; -------  Creating Second Floor Lines   ------------------
        ;;creating second floorline
        (newline 21 up "FLR" nil -12)

        ;;creating second floor ceiling line
        (newline ht2 up "CLG" nil 24)

;;; -------  Creating Second Floor Fascia   ------------------
        ;;creating top of second floor fascia
        (newline 3 dn "WALL" nil -12)

        ;;creating bottom of second floor fascia
        (newline 8 dn "WALL" nil 0)
        (facia_ends)

        (setvar "Osmode" oldsnap)
        (command ".undo" "end")
      ) ; end progn
    ) ;  endif
  ) ; end if
 
  (setvar "Cmdecho" oldecho)
  (princ)

)
(princ)

;;======================
;;    End of Routine
;;======================
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.

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Help with extending
« Reply #2 on: February 05, 2004, 12:57:35 AM »
Fantastic, thank you, I'll run it when I get into work tomorrow.  Glad to be here myself as well  :D