+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 39
  1. #1
    Junior Member
    Using
    Mechanical 2004
    Join Date
    May 2012
    Posts
    14

    Default Is bpoly/boundary creation without user interaction possible?

    Registered forum members do not see this ad.

    Hi everyone,

    New to the forums so let me first say thanks in advance. I'm not a programmer but I dabble so I'm looking for any and all help I can get.

    I currently have a job where I'd like to reduce the time involved on some of our drawings but not sure if what I want to do is even possible.

    Right now, using the bpoly or boundary command the user has to select an internal point to create a closed poly. What I'd like is to eliminate the user interaction. So would it be possible to create a lisp routine that could create a set of closed polys from a selection set similar to the objects in my attached image? In that image the user what have to click four times to create the needed four closed polys. It would be nice if a routine could select all the entities on the set layers and create them without any user interaction.

    More details: The image is a simple example. The lines would always be construction lines but the angle could be anything. They would always offset equal distances (simple array in this case). The rectangle could be any shaped closed polygon, possibly even a circle, though we haven't run into that yet.

    Hopefully that was somewhat understandable. Anything that might help point in the right direction would be great.

    Thanks,
    Darin

    Example_001.jpg

  2. #2
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,615

    Default

    If I understood your idea well ....

    Code:
    (defun c:Test (/ selectionset)
      (vl-load-com)
      ;;; Tharwat 21. may. 2012 ;;;
      (if (setq selectionset (ssget "_x" '((0 . "*POLYLINE") (-4 . "&") (70 . 1))))
        ((lambda (integer / selectionsetname entity)
           (while
             (setq selectionsetname (ssname selectionset (setq integer (1+ integer))))
              (setq entity (vl-remove-if-not (function
                           (lambda (x)
                             (member (car x) '(0 8 10 67 70 90 100 410 210))
                           )
                         )
                         (entget selectionsetname))
              )
              (entmakex entity)
           ))
        -1
      )
        (princ))
    (princ)
    )
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  3. #3
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    2,985

    Default

    Looks to me that the OP wasn't looking to replicate the existing contour, but to create a closed polyline contour on each and every closed areas (colored independently below) defined by intersecting the entities in his/her drawing:

    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  4. #4
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,615

    Default

    I guess you're right Mircea ,
    - When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said

  5. #5
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,088

    Default

    Quote Originally Posted by MSasu View Post
    Looks to me that the OP wasn't looking to replicate the existing contour, but to create a closed polyline contour on each and every closed areas defined by intersecting the entities in his/her drawing:
    Now that makes it a lot easier to code.

  6. #6
    Junior Member
    Using
    Mechanical 2004
    Join Date
    May 2012
    Posts
    14

    Default

    Yes, MSasu, you are correct. Thanks for the clarification.

  7. #7
    Junior Member
    Using
    Mechanical 2004
    Join Date
    May 2012
    Posts
    14

    Default

    So, does anyone have any suggestions? I knew it wasn't going to be easy but thought someone might know if it's possible. If it's not then I'll move on and just do it manually.

    Thanks.

  8. #8
    Forum Deity pBe's Avatar
    Computer Details
    pBe's Computer Details
    Operating System:
    Windows XP
    Discipline
    Construction
    pBe's Discipline Details
    Discipline
    Construction
    Details
    Camp Construction planning and details
    Using
    AutoCAD 2009
    Join Date
    Apr 2010
    Posts
    2,088

    Default

    Quote Originally Posted by Pottersfriend View Post
    So, does anyone have any suggestions? I knew it wasn't going to be easy but thought someone might know if it's possible. If it's not then I'll move on and just do it manually.
    Thanks.
    It is possible, you can doi it manually for now if need be while your'e waiting for someone to get around to it but then again, maybe not, let's just say when it happens, it happens.
    Forum members write the codes on their own time and not restricted by a time limit.

    Are those contour lines with z-coordinates? or just a representation of the contour and at elevation 0? post a drawing example and we'll see what we can come up with.

    ---- like i always say... be patient -----

  9. #9
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,932

    Default

    Very good [mind's] eye for detail, Pbe... The Z could throw some a speed bump. First thought is to create a selection set of these entities, and if a Z were to prevent a standard bpoly, then duplicate each entity (visible = false), flattening them, then produce the desired boundaries, and delete the duplicate (hidden) entities.

    Error handling would allow for duplicates to be deleted no matter what.

    Perhaps seeing (or writing) some code will bring other potential 'gotcha's' to light.
    "Potential has a shelf life." - Margaret Atwood

  10. #10
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,586

    Default

    Registered forum members do not see this ad.

    Here is a dirty method (create duplicate boundaries)
    Try it on your drawing
    Code:
     
    (defun C:BON(/ *error* adoc a ALE_IsInside ang b en frame fuzz group-by-num i ints ipts mp osm p1 p2 pts sset x xline xlines xset)
     
    (defun *error* (msg)
    (vla-endundomark (vla-get-activedocument
    (vlax-get-acad-object))
    )
    (cond ((or (not msg)
    (member msg '("console break" "Function cancelled" "quit / exit abort"))
    )
    )
    ((princ (strcat "\nError: " msg)))
    )
     
    (setvar "cmdecho" 1)
    (if osm (setvar "osmode" osm))
    (princ)
    )
    (defun group-by-num (lst num / ls ret)
    (if (= (rem (length lst) num ) 0)
    (progn
    (setq ls nil)
    (repeat (/ (length lst) num)
    (repeat num (setq ls 
    (cons (car lst) ls)
    lst (cdr lst)))
    (setq ret (append ret (list (reverse ls)))
    ls nil)))
    )
    ret
    )
    (defun ALE_IsInside (ImpPnt EntNam / VlaObj LstEnt NewEnt EntAre)
    ;;; by *Alessi, Marc'Antonio
    (vl-load-com) 
    (setq VlaObj (vlax-ename->vla-object EntNam)) 
    (cond 
    ( (not (vlax-property-available-p VlaObj 'Area)) 
    (not (princ "It isn't possible to compute this object!")) 
    ) 
    ( (equal (vlax-curve-getclosestpointto VlaObj ImpPnt) ImpPnt 1e-10) 
    (not (princ "Point is on object!")) 
    ) 
    ( (and 
    (setq LstEnt (entlast)) 
    (not (command "_.OFFSET" 0.0000001 EntNam "_NONE" ImpPnt "")) 
    (eq LstEnt (setq NewEnt (entlast))) 
    ) 
    (not 
    (princ "It isn't possible to compute this point inside this 
    object!") 
    ) 
    ) 
    ( T 
    (setq EntAre (vlax-get-property (vlax-ename->vla-object NewEnt) 
    'Area)) 
    (entdel NewEnt) 
    (> (vlax-get-property VlaObj 'Area) EntAre) 
    ) 
    ) 
    )
    ;;---------------------------- main part -----------------------;;
     
    (setq adoc (vla-get-activedocument
    (vlax-get-acad-object))
    acsp (vla-get-block(vla-get-activelayout adoc)))
     
    (vla-startundomark adoc )
    (setvar "cmdecho" 0)
    (setq osm (getvar "osmode" ))
    (setvar "osmode" 0)
    (if (setq sset (ssget ":S"
    '((-4 . "<or")
    (-4 . "<and")
    (0 . "LWPOLYLINE")
    (70 . 1)
    (-4 . "and>")
    (0 . "ELLIPSE,CIRCLE")
    (-4 . "or>")
    )
    )
    )
    (progn
    (setq fuzz 1)
    (setq frame (vlax-ename->vla-object (setq en (ssname sset 0))))
    (vla-getboundingbox frame 'minp 'maxp)
    (setq minp (vlax-safearray->list minp)
    maxp (vlax-safearray->list maxp))
    (command "zoom" "w" minp maxp)
     
    (cond ((eq "AcDbPolyline" (vla-get-objectname frame))
    (setq pts (vl-remove-if
    'not
    (mapcar '(lambda (x)
    (if (= 10 (car x))
    (cdr x)
    )
    )
    (entget en)
    )
    )
    ))
    (T (progn(setq leng (vlax-curve-getdistatparam frame (vlax-curve-getendparam frame)))
    (setq n 0 step (/ leng 128))
    (repeat 128
    (setq pts (cons (vlax-curve-getpointatdist frame (* n step)) pts ))
    (setq n (1+ n))))))
    (setq xset (ssget "_CP" pts (list (cons 0 "XLINE"))))
    (setq xlines
    (mapcar 'vlax-ename->vla-object
    (vl-remove-if 'listp (mapcar 'cadr (ssnamex xset)))
    )
    )
    (setq i 0)
    (repeat (length xlines)
    (setq xline (nth i xlines))
    (setq ipts (vla-intersectwith frame xline 0))
    (if (= 0
    (vlax-safearray-get-l-bound
    (setq ipts (vlax-variant-value ipts))
    1
    )
    )
    (progn
    (setq ints (vlax-safearray->list ipts))
    (setq ints (group-by-num ints 3))
    (if (= 2 (length ints))
    (progn
    (setq mp (mapcar '(lambda (a b) (/ (+ a b) 2))
    (car ints)
    (cadr ints)
    )
    )
    (setq ang (angle (vlax-get xline 'basepoint)
    (vlax-get xline 'secondpoint)
    )
    )
    (setq p1 (polar mp (+ ang 0.1) fuzz)
    p2 (polar mp (- ang 0.1) fuzz)
    )
    (if (ALE_IsInside p1 en)
    (vl-cmdf "-boundary" "a" "o" "r" "" p1 "")
    )
    (if (ALE_IsInside p2 en)
    (vl-cmdf "-boundary" "a" "o" "r" "" p2 "")
    )
    )
    )
    )
    )
    (setq i (1+ i))
    )
    )
    )
    (*error* nil)
    (princ)
    )
    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

Similar Threads

  1. mleader / ampoweredit interaction
    By TheDelano in forum AutoCAD General
    Replies: 0
    Last Post: 23rd Apr 2012, 06:35 pm
  2. Mark Errors boundary not edge match with adjacent boundary
    By chvnprasad in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 28th Mar 2012, 04:02 pm
  3. How to using existing autocad command bpoly ? (vba) or (net)
    By ZORANCRO in forum .NET, ObjectARX & VBA
    Replies: 1
    Last Post: 4th Oct 2010, 04:28 pm
  4. Boundary Creation Lisp- a request
    By onzki in forum AutoLISP, Visual LISP & DCL
    Replies: 18
    Last Post: 16th Jul 2010, 03:22 pm
  5. Bpoly trouble
    By quasifun in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 9th Oct 2007, 10:34 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