+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Senior Member JONTHEPOPE's Avatar
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    Canada
    Posts
    237

    Default Code for sq feet

    Registered forum members do not see this ad.

    Code:
     
    ;;;--- GA.lsp   -   GetArea
    ;;;
    ;;;
    ;;;--- Select a spot on the interior of an enclosed area and this program
    ;;;    will write the Plot Number, Area, and Perimeter on that spot.
    ;;;
    ;;;
    ;;;--- This program uses the -bhatch command to create a hatch over the area.
    ;;;    It then gets a list of all of the control points for the hatch and
    ;;;    creates a polyline boundary (using the ENTMAKE) function.  The area
    ;;;    command is used on the polyline to find the area and perimeter.
    ;;;    No islands are taken into consideration.
    ;;;
    ;;;
    ;;;--- Created on 8/6/04
    ;;;    Copyright 2004 by JefferyPSanders.com
    ;;;    All rights reserved.
    ;;;
    ;;;
    ;;;--- Program is issued as is without gauranties of the accuracy nor of
    ;;;    damages resulting from use of the program.
    ;;;
    ;;;
    ;;;--- Tested with AutoCAD Release 14 and 2004
     
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;                                                                          ;;;
    ;;;     888       888          888           8888888      8888   888         ;;;
    ;;;     8888     8888         88888            888        88888  888         ;;;
    ;;;     88888   88888        888 888           888        888888 888         ;;;
    ;;;     888888 888888       888   888          888        888 888888         ;;;
    ;;;     888 88888 888      88888888888         888        888  88888         ;;;
    ;;;     888  888  888     888       888      8888888      888   8888         ;;;
    ;;;                                                                          ;;;
    ;;;                                                                          ;;;
    ;;;                888            888888888        888888888                 ;;;
    ;;;               88888           888   888        888   888                 ;;;
    ;;;              888 888          888   888        888   888                 ;;;
    ;;;             888   888         888888888        888888888                 ;;;
    ;;;            88888888888        888              888                       ;;;
    ;;;           888       888       888              888                       ;;;
    ;;;                                                                          ;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    (defun C:GA()
      ;;;--- Turn the command echo off
      (setvar "cmdecho" 0)
      ;;;--- Inform the user of the plot number
      (princ "\n Starting Number is ")(princ (getvar "useri1"))
      (princ ".   To change this, reset the system variable USERI1")
      ;;;--- Get the interior selection point
      (setq pt(getpoint "\n Select Interior of Area : "))
      ;;;--- Create a hatch pattern in the area
      (command "-bhatch" "Advanced" "Island" "No" "Nearest" "" pt "")
      ;;;--- If the hatch pattern was created...
      (if(setq en(entlast))
        (progn
          ;;;--- Get the dxf group codes from the hatch entity
          (setq enlist(entget en))
          ;;;--- Build a list to eventually make a polyline entity
          (setq plist(list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline")))
          ;;;--- Set up an empty list, a flag, and a counter
          (setq newList(list) flag 0 cntr 0)
          ;;;--- Cycle through every item in the hatch's dxf group codes
          (while(< cntr (length enlist))
            ;;;--- Get the first item
            (setq a(nth cntr enlist))
            ;;;--- If it is the first group code 10, increment the flag and proceed
            (if (= (car a) 10)(setq flag(+ flag 1)))
            ;;;--- Skip the first group code 10 in the entity list
            (if (> flag 1)
              ;;;--- If the dxf group code number is 10, then...
              (if(= (car a) 10)
                (progn
                  ;;;--- Start a temporary list holding the dxf group codes for a VERTEX entity
                  ;;;    Add codes 0 and 10
                  (setq tmp(list (cons 0 "VERTEX") a))
                  ;;;--- In case there are bulges, look for codes 42 and 50 while the next code isn't
                  ;;;    a group code 10 and there are more items in the dxf group codes to look for.
                  (while(and (< cntr (length enlist))(/= (car (nth (+ cntr 1) enlist)) 10))
                    ;;;--- Increment the counter to get to the 42 and 50 codes
                    (setq cntr(+ cntr 1))
                    ;;;--- Get the next code 
                    (setq b(nth cntr enlist))
                    ;;;--- If it is a 42 or 50 code...
                    (if(or (= (car b) 42)(= (car b) 50))
                      ;;;--- Add it to the temporary list
                      (setq tmp(append tmp (list b)))
                    )
                  )
                  ;;;--- Add the temporary list to the new list
                  (setq newList(append newList (list tmp)))
                )
              )
            )
            ;;;--- Increment the counter to get the next group 10 code
            (setq cntr(+ cntr 1))
          )
          ;;;--- In order to close the polyline, we will need to save the start point
          ;;;    and use it later as the end point of the polyline
          (setq lastPt(car newList))
          ;;;--- Strip off the last point, which is the point selected during the hatch command
          (setq newList(reverse(cdr(reverse newList))))
          ;;;--- Delete the hatch pattern
          (entdel en)
          ;;;--- Start creating the polyline entity
          (entmake 
            (list 
              (cons 0 "POLYLINE")   ; Object type
              (cons 66 1)           ; Vertices follow
            )
          )
          ;;;--- Add each vertex to the polyline entity...
          (foreach a newList
            (entmake a )
          )
          ;;;--- Close the polyline by adding the first point
          (entmake lastPt)
          ;;;--- Finally add the SEQEND to create the polyline
          (entmake (list (cons 0 "SEQEND")))    
          ;;;--- Get the entity name of the polyline just created
          (setq en(entlast))
          ;;;--- Use the area command on the polyline
          (command "area" "Object" en)
          ;;;--- Get the Area of the Polyline
          (setq myArea(getvar "area"))    
    
          ;;;--- NOTE: Here would be a good place to do any manipulation of the area.
          ;;;    Such as converting it to square feet or acres.
    
          ;;;--- Get the perimeter of the polyline
          (setq myPerim(getvar "perimeter"))
    
          ;;;--- NOTE: Here would be a good place to do any manipulation of the perimeter.
          ;;;          Such as converting to feet or meters.
     
          ;;;--- Get the plot number to use from the USERI1 system variable.
          (setq myNum(getvar "useri1"))
          ;;;--- Don't start with zero, which is Autocad's default
          (if(= myNum 0)(setq myNum 1))
          ;;;--- Increment the counter before saving for next time
          (setvar "useri1" (+ myNum 1))
          ;;;--- Convert the number to a string
          (setq myNum(itoa myNum))
          ;;;--- Grab the current textsize
          (setq tht(getvar "textsize"))
          ;;;--- Get the current text style
          (setq csty(getvar "textstyle"))
          ;;;--- See if the text style has a preset height
          (if(= 0 (cdr(assoc 40(tblsearch "style" csty))))
            (progn
              ;;;--- Insert the text with a height parameter
              (command "text" "Justify" "Center" Pt tht 0 myNum)
              (command "text" "Justify" "Center" (polar Pt (* pi 1.5) (* tht 1.5)) tht 0 (strcat "AREA=" (rtos myArea 2 4)))
              (command "text" "Justify" "Center" (polar Pt (* pi 1.5) (* 2.0(* tht 1.5))) tht 0 (strcat "PERIMETER=" (rtos myPerim)))
            )
            (progn
              ;;;--- Else, Insert the text without a height parameter
              (command "text" "Justify" "Center" Pt 0 myNum)
              (command "text" "Justify" "Center" (polar Pt (* pi 1.5) (* tht 1.5)) 0 (strcat "AREA=" (rtos myArea 2 4)))
              (command "text" "Justify" "Center" (polar Pt (* pi 1.5) (* 2.0(* tht 1.5))) 0 (strcat "PERIMETER=" (rtos myPerim)))
            )
          )
          ;;;--- Delete the polyline entity
          (entdel en)
        )
        (alert "Hatch pattern could not be created.  Make sure the area is enclosed.")
      )
      ;;;--- Turn the command echo back on
      (setvar "cmdecho" 1)
      ;;;--- Suppress the last echo for a clean exit
      (princ)
    )





    HI GUYS/GIRLS I FOUND THIS CODE WRITEN BY JPSANDERS AND IT DOES SO MUCH BUT I WOULD LIKE IT TO WRITE SQ FEET . I KNOW THERES A SPOT FOR ME TO WRITE CODE BUT I DONT KNOW HOW.?
    ANY HELP WOULD BE NICE THANKS
    THE HOLY ONE

  2. #2
    Senior Member mrbucket's Avatar
    Computer Details
    mrbucket's Computer Details
    Operating System:
    Windows 7 Ultimate
    Computer:
    Antec 9Hundred
    Motherboard:
    ASRock A780GXE 128M
    CPU:
    AMD Phenom Quad 9950@3.0ghz
    RAM:
    4 Gigs OCZ Dominator@1333, 4 Gigs Flash Mem L3 Cache
    Graphics:
    Radeon 8670 HD 1 gig
    Primary Storage:
    Seagate Barracuda 500 Gig 16 mb Cache
    Monitor:
    22" Sceptre HD
    Using
    Architecture 2010
    Join Date
    Aug 2007
    Location
    Brick, N.J. USA
    Posts
    271

    Default

    CAPS LOCK IS AWESOME!

    Your gonna spend more time getting it to work, and it will still have problems.
    How much Sq. Ft. are you planning on figuring out? I can get a Sq. Ft. for a 6000 sq.ft. house in under 30 sec. on a tough one. What kind of project are you doing?
    My ESC key is worn out.


  3. #3
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,780

    Default

    Why wouldn.t you just use BP boundary poly then write answer. Dont reinvent the wheel.

    Search here for write closed poly line answers as text, length area etc also as field change shape and it updates !

  4. #4
    Senior Member GhostRider's Avatar
    Computer Details
    GhostRider's Computer Details
    Operating System:
    Windows Vista Business
    Computer:
    Dell Optiplex 755
    Motherboard:
    Dell
    CPU:
    Intell Core 2 DUO 2.8ghz
    RAM:
    3 GIG
    Graphics:
    Ati RAEDON HD 2400 Dual -512 Ram
    Primary Storage:
    160 Gigger
    Monitor:
    Dual Acer 22"
    Discipline
    Architectural
    GhostRider's Discipline Details
    Occupation
    Residential Engineering/Contracting
    Discipline
    Architectural
    Using
    AutoCAD 2011
    Join Date
    Aug 2007
    Location
    N. Carolina
    Posts
    401

    Default

    He's a made a provision for such an addition to the code in the area shown below, it's above my knowledge of LISP though.

    Code:
     ;;;--- Use the area command on the polyline
          (command "area" "Object" en)
          ;;;--- Get the Area of the Polyline
          (setq myArea(getvar "area"))    
     
          ;;;--- NOTE: Here would be a good place to do any manipulation of the area.
          ;;;    Such as converting it to square feet or acres.
     
          ;;;--- Get the perimeter of the polyline
          (setq myPerim(getvar "perimeter"))
     
          ;;;--- NOTE: Here would be a good place to do any manipulation of the perimeter.
          ;;;          Such as converting to feet or meters.
    This is a simple SQFT calc that works by picking the corners if you need it
    Code:
    ;;                         SQFT Area Lisp Program
    ;;                               
    ;;                  WRITTEN:November 11, 1994
     
    (defun c:rar (/    P1  P2    P3    P4    P5  P6    A     B
          C    D  E     F     PT    PTLIST      OS    ss
          ssl   wl  ctr   l1    l2    wn  wlist llist vlist
          bn    dlist dllist      dvlist
         )
      (setvar "CMDECHO" 0)
      (setq wl 0)
      (setq E 0)
      (setq D 0)
      (setq OS (getvar "OSMODE"))
        (setq l1 70)
      (setvar "OSMODE" 32)
      (while (/= nil
          (setq PT
          (getpoint
            "\nPick a room corner point, press return when done: _int "
          )
          )
          (progn
            (if PT
       (/= nil (setvar "lastpoint" PT))
            )
            (setq PTLIST (cons PT PTLIST))
          )
      )
      )
      (setq PTLIST (reverse PTLIST))
      (setvar "OSMODE" 0)
      (command "PLINE")
      (while (/= nil
          (car PTLIST)
          (progn
            (command (car PTLIST))
            (setq PTLIST (cdr PTLIST))
          )
      )
      )
      (command "AREA" "e" "l" "ERASE" "l" "")
      (setvar "OSMODE" OS)
      (command "redraw")
      (setq A (/ (getvar "area") 144))
     
      (setq P1 (getpoint "\nPick center point of text: "))
      (setq P2 (list (car P1) (- (cadr P1) 5)))
      (setq P3 (list (car P1) (- (cadr P2) 5)))
      (setq P4 (list (car P1) (- (cadr P3) 5)))
      (setq P5 (list (car P1) (- (cadr P4) 5)))
      (setq P6 (list (car P1) (- (cadr P5) 5)))
      (command "text" "c" P1 6 0 (strcat (rtos A 2 2) " SQFT."))
      (setvar "cmdecho" 1)
      (princ)
    )
    So many commands, so little time....

  5. #5
    Senior Member JONTHEPOPE's Avatar
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    Canada
    Posts
    237

    Default Caps

    I WORK ON ALOT OF DIFFERENT PROJECTS. AND NEED THE AREA FOR EACH ROOM FOR CFM CONVERSION. I TAKE SQ FT AND X BY HEIGHT AND AIR CHANGE THAN / BY 60 .. guess i could take caps off.
    i use a script,lisps, and am trying to learn vb .. ive used a cad for 8 years and dont think i use it very well cause i cant write my own code .(yet) but every day i learn a bit more.

    THE HOLY ONE

  6. #6
    Senior Member JONTHEPOPE's Avatar
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    Canada
    Posts
    237

    Default Yes

    Thanks Ghost Rider
    Its Good . But I Still Donno Know How You Comb Your Hair???:p
    THE HOLY ONE

  7. #7
    Senior Member GhostRider's Avatar
    Computer Details
    GhostRider's Computer Details
    Operating System:
    Windows Vista Business
    Computer:
    Dell Optiplex 755
    Motherboard:
    Dell
    CPU:
    Intell Core 2 DUO 2.8ghz
    RAM:
    3 GIG
    Graphics:
    Ati RAEDON HD 2400 Dual -512 Ram
    Primary Storage:
    160 Gigger
    Monitor:
    Dual Acer 22"
    Discipline
    Architectural
    GhostRider's Discipline Details
    Occupation
    Residential Engineering/Contracting
    Discipline
    Architectural
    Using
    AutoCAD 2011
    Join Date
    Aug 2007
    Location
    N. Carolina
    Posts
    401

    Default

    From the lisps Ive seen what you need doesn't sound too hard for a lisp or VBA GURU to do, it's over my capabilities. a simple dialog box to set the ceiling height, air changes then the area selected / 60 ..
    Good Luck,

    (Btw: I have a few little cuties buff my skull)
    So many commands, so little time....

  8. #8
    Super Moderator Lazer's Avatar
    Computer Details
    Lazer's Computer Details
    Operating System:
    Windows 7
    Computer:
    HP xw 4600 Workstation
    CPU:
    Intel Core2 Duo, 3 Gig
    RAM:
    8GB
    Graphics:
    NVIDEA Quadro FX 1700
    Primary Storage:
    1TB
    Secondary Storage:
    Portable TB drive
    Monitor:
    Samsung SyncMaster 226
    Using
    Inventor 2013
    Join Date
    Aug 2005
    Location
    Northants, England
    Posts
    1,565

    Default

    JONTHEPOPE I have renamed the thread, typing 'STUCK' as the thtrad title will not help others find this thread while they search the threads
    USING AUTOCAD 2013 AND INVENTOR 2013, ALIAS 2013.

    If in doubt scale and don't ask!



  9. #9
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,780

    Default

    Registered forum members do not see this ad.

    You can add a "thickness" to a polyline this is equivalent to a height. Set thicknes to say 8' draw a pline then vpoint 1,1,1, you should see the pline in 3d. You can then write the answer as a field if you change one of the variables the text will change.

    try this
    (defun c:ca ( / ent strField objID)
    ;; select an object
    (if (setq ent (entsel))
    (progn
    (setq ent (car ent))

    ;; check to see if the object selected is a polyline
    (if (= (cdr (assoc 0 (entget ent))) "LWPOLYLINE")
    (progn
    ;; Obtain the object id from the selected entity
    (setq objID (vla-get-objectid (vlax-ename->vla-object ent)))
    ;; Create the Field expression

    (setq strField
    (strcat "%<\\AcObjProp Object(%<\\_ObjId "
    (rtos objID 2 0)
    ">%).Area \\f \"%lu6%qf1%ps[, ha]%ct8[0.0001]\">%"
    )
    )

    ;; Use the -TEXT command to create a single line text object with
    ;; Field expression
    (command "._-text" "J" "M" (getpoint) 2.1 90 strField)
    )
    (prompt "\nObject selected was not a Lightweight Polyline")
    )
    )
    (prompt "\nNo Object selected")
    )

    ;; Exit quietly
    (princ)
    )

Similar Threads

  1. Dimensioning in feet and inches
    By Sheryl in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 14th Apr 2008, 01:17 pm
  2. Inches rather then feet
    By siderus in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 13th Mar 2008, 05:06 pm
  3. Inches instead of feet
    By siderus in forum AutoCAD General
    Replies: 3
    Last Post: 16th May 2007, 08:46 pm
  4. Feet & Inches
    By ebjco in forum AutoCAD Drawing Management & Output
    Replies: 5
    Last Post: 6th Oct 2006, 02:36 pm
  5. inches to feet
    By giloosh in forum AutoCAD Beginners' Area
    Replies: 5
    Last Post: 13th Sep 2005, 10:49 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts