Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How to check if an "boundary" is closed

  1. #1
    Member
    Join Date
    2001-10
    Posts
    3
    Login to Give a bone
    0

    Post How to check if an "boundary" is closed

    Any one who have a clue or even better a lisp-file which checks if a "boundary" with lines and polylines is correct closed .
    I want to retain original objects and NOT create new objects.
    If its closed then print the area else print error message.

    Stefan SWEDEN

  2. #2
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: How to check if an "boundary" is closed

    bpoly, if it's not closed, it will just display an error, if it is closed, it'll just create a pline of the boundary.

  3. #3
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: How to check if an "boundary" is closed

    Something like this?
    Code:
    ;;; Command to get area of closed polyline
    (vl-load-com)
    (defun c:CPLArea (/ en ed eo)
      (while (setq en (entsel "Pick a polyline: "))
        (setq ed (entget (car en)))
        (if (or
              (= "LWPOLYLINE" (cdr (assoc 0 ed)))
              (= "POLYLINE" (cdr (assoc 0 ed)))
            ) ;_ end of or
          (if (> (logand (cdr (assoc 70 ed)) 1) 0)
            (progn
              (setq eo (vlax-ename->vla-object (car en)))
              (princ "The polyline's area is ")
              (princ (vla-get-Area eo))
              (princ "\n")
            ) ;_ end of progn
            (princ "The polyline's not closed ... no area.\n")
          ) ;_ end of if
          (princ "The entity you selected is not a polyline. Please try again\n")
        ) ;_ end of if
      ) ;_ end of while
      (princ)
    ) ;_ end of defun

  4. #4
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: How to check if an "boundary" is closed

    This simple one do calculate an area inside all kind of legal objects,
    BUT it temporary create a region that is removed.
    Code:
    (defun c:ACa ( / PickPoint LastEnt ) ; AreaCalculate
      (if (setq PickPoint (getpoint "Pick a point inside the area : " ) )
        (progn
          (setq LastEnt (entlast))
          (command "._-boundary" "A" "O" "R" "" PickPoint "" )
          (if (not (eq (entlast) LastEnt ))
            (progn
              (prompt " temporary, that is removed. " )
              (princ (strcat "\nArea = " (rtos (getvar "AREA" )) "" " xxx2" ) )
              (command "._erase" (entlast) "" )
            )
            (princ "No area to calculate. " )
          )
        )
        (princ ". . no point picked. " )
      )
      (princ)
    )
    
    : ) Happy Computing !
    
    kennet

  5. #5
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: How to check if an "boundary" is closed

    here's what i use; i wrote this because i hate how LDD's parcel labeler uses attributed blocks. if the boundary is not closed, nothing happens. it will increment from a starting point (1 if nil, or 1+ the last number used) and it will use allow for a prefix for the lot/parcel, etc. (ie: LOT 1, PARCEL 1, CONSERVATION EASEMENT #5)
    below the label, it will place the acreage "2.22 AC.±" and the acerage and square footage will be printed on the command line.
    result: LOT 5
    2.25 AC.±
    created text is middle center justified mtext.

    Code:
    ;get area of closed boundary
    ;will allow user to specify a prefix (ie: Lot, Parcel), starting number (ie: 1, 2) and pick point
    ;inside a closed boundary (pline not required). it will place a piece of mtext where picked with
    ;the prefix, number and acerage (ie: Lot 1 - next line - 0.25 Ac.±)
    ;the user may continue to picked closed areas and the number will increase by one
    
    ;CREATED BY: alan thompson 11.28.07
    ;UPDATED BY: alan thompson 12.19.07 (mtext instead of dtext, lot numbering works better, etc.)
    ;UPDATED BY: alan thompson 4.22.08 (added ability to enter more than 1 word for prefix)
    ;UPDATED BY: alan thompson 6.10.08 (rearranged code so dimzin isn't changed unless boundary can be created)
    ;updated by: alan thompson 6.24.08 (added title, localized variables, changed code to remember last "Number Prefix"
    ;                    and "Lot Number" used, if "Number Prefix" is nil, "LOT" is used, if "Lot Number"
    ;                    is nil, "1" is used)
    
    (defun c:GA (/ dzin num_prefix ins lot_number ar acre txt)
        (if (= *lot_number nil)
            (setq *lot_number 1)
        );if
        (if (= *num_prefix nil)
            (setq *num_prefix "LOT")
        );if
        (setq DZIN (getvar "dimzin"))
        (setq num_prefix (getstring T (strcat "\Enter Number Prefix (Lot, Parcel, etc.) <" *num_prefix ">: ")))
        
        (if (= num_prefix "")
            (setq num_prefix *num_prefix)
            (setq *num_prefix num_prefix)
        );if
        (setq ins 1)
        (setq lot_number (getint (strcat "\Enter First Lot Number <" (rtos *lot_number) ">: ")))
        
        (if (= lot_number nil)
            (setq lot_number *lot_number)
            (setq *lot_number lot_number)
        );if
        (while        
            (if (setq ins (getpoint "\nPick Number Location: "))
                (progn
                    (command "-boundary" ins "")
                    (command "area" "o" "l")
                    (command "erase" "l" "")
                    (setvar 'dimzin 0)
                    (setq AR (getvar "area"))
                    (setq ACRE (strcat (rtos (/ (getvar "area") 43560) 2 2) " AC.±"))
                    (setq txt (strcat num_prefix " " (rtos lot_number 2 0)))
                    (command "mtext" ins "j" "mc" ins txt ACRE "")
                    (setq lot_number (1+ lot_number))
                    (setq *lot_number lot_number)
                    (setvar 'dimzin DZIN)
                    (princ (strcat "\n" ACRE " & " (rtos (getvar "area") 2 2) " SQ. FT."))
                );progn
            );if setq ins
        );WHILE
        (princ)
    );defun

  6. #6
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: How to check if an "boundary" is closed

    Quote Originally Posted by alanjt View Post
    here's what i use; i wrote this because i . . .
    Great,

    but if a boundary is not created ( -boundary command fail ) your program still erase last object.
    For safety reason, add my security check in previous post to avoid erasing wrong "last" object.

    : ) Happy Computing !

    kennet

  7. #7
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: How to check if an "boundary" is closed

    Quote Originally Posted by kennet.sjoberg View Post
    Great,

    but if a boundary is not created ( -boundary command fail ) your program still erase last object.
    For safety reason, add my security check in previous post to avoid erasing wrong "last" object.

    : ) Happy Computing !

    kennet
    never been an issue for me, if the -boundary function fails, the routine exits. i just tested it, just to make sure.

    this is picking inside lines that do no close:
    Command: ga
    Enter Number Prefix (Lot, Parcel, etc.) <LOT>:
    Enter First Lot Number <1.0000>:

    Pick Number Location:
    Valid hatch boundary not found.
    Selected object does not have an area


    *Invalid selection*
    Expects a point or Last
    did it actually delete the incorrect last object for you, or are you just saying this from a look at the coding? if this is an issue, i'd like to know so i can remedy the issue.

  8. #8
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: How to check if an "boundary" is closed

    Quote Originally Posted by alanjt View Post
    never been an issue for me. . .
    But objects are deleted . . .
    Quote Originally Posted by alanjt View Post
    . . . are you just saying this from a look at the coding?
    Yes, just looking at the code.

    But try this : Open a new drawing and draw one circle
    use your code outside the circle ( -boundary command fail ) and your last circle is poofff...

    : ) Happy Computing !

    kennet

  9. #9
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: How to check if an "boundary" is closed

    ...oops, when writing direct into the forum it is easy to miss something.
    This time I missed the main thing ( marked in red ) try the code again please.
    Code:
    (defun c:ACa ( / PickPoint LastEnt ) ; AreaCalculate
      (if (setq PickPoint (getpoint "Pick a point inside the area : " ) )
        (progn
          (setq LastEnt (entlast))
          (command "._-boundary" "A" "O" "R" "" PickPoint "" )
          (if (not (eq (entlast) LastEnt ))
            (progn
              (prompt " temporary, that is removed. " )
              (command "._area" "O" (entlast) )
              (princ (strcat "\nArea = " (rtos (getvar "AREA" )) "" " xxx2" ) )
              (command "._erase" (entlast) "" )
            )
            (princ "No area to calculate. " )
          )
        )
        (princ ". . no point picked. " )
      )
      (princ)
    )
    : ) Happy Computing !

    kennet

  10. #10
    AUGI Addict
    Join Date
    2008-02
    Posts
    1,141
    Login to Give a bone
    0

    Default Re: How to check if an "boundary" is closed

    Quote Originally Posted by kennet.sjoberg View Post
    But objects are deleted . . .


    Yes, just looking at the code.

    But try this : Open a new drawing and draw one circle
    use your code outside the circle ( -boundary command fail ) and your last circle is poofff...

    : ) Happy Computing !

    kennet
    holy missed pick batman!
    you were completely right. it's odd, when you pick inside a set of lines that are not closed, it will just exit with the error i showed above, i'd never tested it by just picking a point in an open space. i will definitely fix this, hopefully i'll get a chance to do it this weekend. thanks

Page 1 of 2 12 LastLast

Similar Threads

  1. "IF you want to hatch an area whose boundary is not quite closed"
    By Sureshrrai in forum AutoCAD Tips & Tricks
    Replies: 14
    Last Post: 2013-06-11, 01:58 PM
  2. Replies: 10
    Last Post: 2010-03-11, 12:49 PM

Posting Permissions

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