Results 1 to 5 of 5

Thread: Looking for routine...Polyline box around a polyline

  1. #1
    Member
    Join Date
    2011-04
    Location
    Phoenix, AZ
    Posts
    2
    Login to Give a bone
    0

    Default Looking for routine...Polyline box around a polyline

    Hi all. I'm looking to see if anyone may have some code that draws a polyline box around a polyline that the user selects and then fills with a hatch. I currently have a routine that does this however, it is buried in a lisp program with other routines and I can't find the parts I need to cannabilize. Any help would be greatly appreciated.

    Thanks
    Ivan

  2. #2
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    560
    Login to Give a bone
    0

    Wink Re: Looking for routine...Polyline box around a polyline

    You may find some useful code here...

    M.R.

  3. #3
    Member
    Join Date
    2011-02
    Posts
    15
    Login to Give a bone
    0

    Default Re: Looking for routine...Polyline box around a polyline

    Code:
    ;;;we can set the hatch pattern, scale and ofset diastance later.. N. Adam
    ;;;and you can select more than one lwpolylines, this time only for one pline..
    ;;;if this is okey, I'll change for multiple selection.
    (defun c:h1 ()
     (setq ofdis 100)
     (setq pl1 (ssget":L"'((0 . "LWPOLYLINE"))))
     (if (= pl1 nil)(alert "No PolyLine Selected")(YES)
     )
     (princ)
    )
    (defun yes ()
     (setq pl1-0 (ssname pl1 0))
     (setq pl1-1 (entget pl1-0))
     (setq pl1-2 (reverse pl1-1))
     (setq ref-p1 (cdr(assoc 10 pl1-1)))
     (command "copy" pl1-0 "" ref-p1 ref-p1)(setq props (entlast))
     (setq pl1-1 (subst (cons 100 "0")(assoc 10 pl1-1) pl1-1))
     (setq ref-p2 (cdr(assoc 10 pl1-1)))
     (setq ref-p4 (cdr(assoc 10 pl1-2)))
     (setq pl1-2 (subst (cons 100 "0")(assoc 10 pl1-2) pl1-2))
     (setq ref-p3 (cdr(assoc 10 pl1-2)))
     (setq ang1 (angle ref-p2 ref-p1))(setq ang1-a (+ ang1 1.5708))
     (setq newp1 (polar ref-p1 ang1 ofdis))
     (setq ang2 (angle ref-p3 ref-p4))(setq ang2-a (+ ang2 1.5708))
     (setq newp2 (polar ref-p4 ang2 ofdis))
     (setq newp3 (polar newp1 ang1-a ofdis))
     (setq newp4 (polar newp2 ang2-a ofdis))
     (setq props1 (entget props) props2 (reverse props1))
     (setq props1 (subst (cons 10 newp1)(assoc 10 props1) props1))
     (setq props2 (subst (cons 10 newp2)(assoc 10 props2) props1))
     (entmod props1)(entmod props2)
     (command "offset" ofdis props newp3 "")(setq of1 (entlast))
     (command "offset" ofdis props newp4 "")(setq of2 (entlast))
     (command "erase" props "")
     (setq ofs1 (cdr(assoc 10 (entget of1))))
     (setq ofs2 (cdr(assoc 10 (entget of2))))
     (command "pline" ofs1 ofs2 "")(setq of3 (entlast))
     (command "pedit" of1 "j" of2 of3 "" "c" "")
     (command "-bhatch" "s" (entlast) "" "")
    )

  4. #4
    Member
    Join Date
    2011-02
    Posts
    15
    Login to Give a bone
    0

    Default Re: Looking for routine...Polyline box around a polyline

    ;;;we can set the hatch pattern, scale and ofset diastance later.... N. Adam
    ;;;Now this can run in more than one LWPOLYLINE....
    Code:
    (defun c:h1 ()
     (setq ofdis 100)
     (setq pl1 (ssget":L"'((0 . "LWPOLYLINE"))))
     (if (= pl1 nil)(alert "No PolyLine Selected")(YESs)
     )
     (princ)
    )
    (defun yess ()(setq plns 0)
     (setq plnss (sslength pl1))
     (repeat plnss
      (yes)(setq plns (+ plns 1))
     )
    )
    (defun yes ()
     (setq pl1-0 (ssname pl1 plns))
     (setq pl1-1 (entget pl1-0))
     (setq pl1-2 (reverse pl1-1))
     (setq ref-p1 (cdr(assoc 10 pl1-1)))
     (command "copy" pl1-0 "" ref-p1 ref-p1)(setq props (entlast))
     (setq pl1-1 (subst (cons 100 "0")(assoc 10 pl1-1) pl1-1))
     (setq ref-p2 (cdr(assoc 10 pl1-1)))
     (setq ref-p4 (cdr(assoc 10 pl1-2)))
     (setq pl1-2 (subst (cons 100 "0")(assoc 10 pl1-2) pl1-2))
     (setq ref-p3 (cdr(assoc 10 pl1-2)))
     (setq ang1 (angle ref-p2 ref-p1))(setq ang1-a (+ ang1 1.5708))
     (setq newp1 (polar ref-p1 ang1 ofdis))
     (setq ang2 (angle ref-p3 ref-p4))(setq ang2-a (+ ang2 1.5708))
     (setq newp2 (polar ref-p4 ang2 ofdis))
     (setq newp3 (polar newp1 ang1-a ofdis))
     (setq newp4 (polar newp2 ang2-a ofdis))
     (setq props1 (entget props) props2 (reverse props1))
     (setq props1 (subst (cons 10 newp1)(assoc 10 props1) props1))
     (setq props2 (subst (cons 10 newp2)(assoc 10 props2) props1))
     (entmod props1)(entmod props2)
     (command "offset" ofdis props newp3 "")(setq of1 (entlast))
     (command "offset" ofdis props newp4 "")(setq of2 (entlast))
     (command "erase" props "")
     (setq ofs1 (cdr(assoc 10 (entget of1))))
     (setq ofs2 (cdr(assoc 10 (entget of2))))
     (command "pline" ofs1 ofs2 "")(setq of3 (entlast))
     (command "pedit" of1 "j" of2 of3 "" "c" "")
     (command "-bhatch" "s" (entlast) "" "")
    )

  5. #5
    Member
    Join Date
    2011-04
    Location
    Phoenix, AZ
    Posts
    2
    Login to Give a bone
    0

    Default Re: Looking for routine...Polyline box around a polyline

    Thanks for the code Adam. I was able to add the parts to control the offset distance, hatch type and scale.

    Couple of questions however. Is there a way to have the routine also select 2d polylines? I was working with it and it doesn't want to pick the 2d polyline types. I'm not sure on how to write out the selection to allow for 2d polylines.

    The other question is this. Is it possible to have the polyline box be at the length of the end points of the polyline selected? I don't believe this will work since this routine is using an offset of the selected line.

Similar Threads

  1. upgrade Polyline break routine
    By feargt in forum AutoLISP
    Replies: 23
    Last Post: 2013-04-30, 07:52 AM
  2. Polyline Segment LSP Routine Help
    By ann.wozniak in forum AutoLISP
    Replies: 10
    Last Post: 2012-11-25, 09:51 AM
  3. Replies: 14
    Last Post: 2007-09-10, 05:01 PM
  4. Replies: 27
    Last Post: 2006-09-26, 06:15 PM
  5. Splining a Polyline in a routine.
    By Mtn Biker ARM in forum AutoLISP
    Replies: 2
    Last Post: 2006-04-12, 01:13 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
  •