Results 1 to 6 of 6

Thread: Select all and only entities within a polyline

  1. #1
    Member
    Join Date
    2004-01
    Posts
    5
    Login to Give a bone
    0

    Default Select all and only entities within a polyline

    ***** Update - possible error ******
    Upon redrawing the new polyline using the new polyine bptlst, I found that the redraw (manually) did not infact draw directly on top of the offset polyline. It was close but not dead on. I would have thought it should have snagged it anyway. so others may have similar results. I have my ddunits precision set to 1/1000

    I have researched this quite a bit. I am fully aware that it has been addressed over the months and years however the answers were limited. Where I work, our drawings use several hundred polylines. These polylines have at least one or more sides on top of another adjacent polyline just like a puzzle. I am using the ssget function then I select the outer polyline and obtain everything inside the selection. Using "_WP" is not complete because it does not select those entities that touch the polyline. Whereas "_CP" does in fact work, with one exception and that is it also selects those polylines that flank it which I am trying to prevent. I create a boundary point list of the polyline and feed those points to get the contents with CP but it will get any other polyline that sits directly on the same vertice.
    So I thought I would "Offset" my selection set inside the first polyline. This becomes my new polyline as well as my new boundary points. I offset it a fraction of an inch so as to get everything inside. It errors on the line (SETQ entST (SSGET "_CP" bptlst)) for some reason it turns to nil.
    I have include two programs. The first one works and it gets past this line however it also selects all flanking polylines. I have included the first one to show you that it works.
    the second code does basically the same thing however it offsets the polyline and that is what I am trying to use for my new bptlst or boundary points list. it then errors on the line listed above and I am unable to figure out why since it is very similar to the first.

    Thank you in advance.

    First code:
    Code:
    (DEFUN C:PSt	()
      (SETQ plst nil)
      (SETQ bptlst nil)
      (setq i nil)
      (IF (/= (GETVAR "WORLDUCS") 1)
        (SETQ ucsvar (GETVAR "ucsname"))
        )
      (VL-CMDF "ucs" "")
      (SETQ poly (CAR (ENTSEL "Select a polyline on the STAIR Layer: ")))
      
      (SETQ plst (ENTGET poly))
      (FOREACH n plst
        (IF	(= 10 (CAR n))
          (SETQ bptlst (CONS (CDR n) bptlst))
          )
        )
      (SETQ entST (SSGET "_CP" bptlst))   ; here is the problem it grabs the flanking polyline as well.
      (setq entTXT '((0 . "MTEXT")(8 . "TEXT-COMM")))
      (repeat (setq i (sslength entST))
          (SETQ i (1- i))
        (if (= "MTEXT" (CDR(ASSOC 0 (ENTGET (setq e (ssname entST i))))))
          (SSDEL e entST ))
        );repeat
      (SETQ entST (SSDEL poly entST))
      (VL-CMDF "CHPROP" entST "" "LA" "GRAPHIC-STAIR" "")
      (VL-CMDF "CHPROP" poly "" "LA" "POLY-STAIR" "")
    )
    Second variation trying to use offset of the selection:
    please note that there is a defun to obtain the inside direction.
    Code:
    (DEFUN C:offsetENT ()
      (VL-LOAD-COM)
      (SETQ poly (CAR (ENTSEL "Select a polyline on the STAIR Layer: ")))
      (WCMATCH (CDR (ASSOC 0 (ENTGET poly))) "*POLYLINE")
      (SETQ d 0.01)					  ;(SETQ d (GETDIST "\nOffset distanse: "))
      (SETQ POLY (VLAX-ENAME->VLA-OBJECT POLY))
      (VLAX-WRITE-ENABLED-P POLY)
      (VLAX-METHOD-APPLICABLE-P POLY 'Offset)
      (IF (pline_clockwise POLY)
        d
        (SETQ d (- 0 d)) ;_ Plus or minus To change a sign
        )
      (SETQ i 1)
      (VLA-OFFSET POLY (* i d))			  ; This is where the polyline is offset
      (setq ofsetPOLY (entlast))
      (SETQ newPLST (ENTGET ofsetPOLY))		  ;Now that the polyline is offset grab it and walk thru the bptlist
      (FOREACH n newPLST
        (IF	(= 10 (CAR n))
          (SETQ bptlst (CONS (CDR n) bptlst))
          )
        )
      (SETQ entST (SSGET "_CP" bptlst))		  ; this is the error it works for the other program but here it is ni
      (SETQ entTXT '((0 . "MTEXT") (8 . "TEXT-COMM")))
      (REPEAT (SETQ i (SSLENGTH entST))
        (SETQ i (1- i))
        (IF	(= "MTEXT" (CDR (ASSOC 0 (ENTGET (SETQ e (SSNAME entST i))))))
          (SSDEL e entST)
          )
        )						  ;repeat
      (SETQ entST (SSDEL ofsetPOLY entST))
      (VL-CMDF "CHPROP" entST "" "LA" "GRAPHIC-STAIR" "")
      (VL-CMDF "CHPROP" poly "" "LA" "POLY-STAIR" "")
      )
    
    (DEFUN pline_clockwise (lw / LST MAXP MINP)
      (IF (= (TYPE lw) 'ENAME)
        (SETQ lw (VLAX-ENAME->VLA-OBJECT lw))
        )
      (VLA-GETBOUNDINGBOX lw 'MinP 'MaxP)
      (SETQ	minp (VLAX-SAFEARRAY->LIST minp)
    	MaxP (VLAX-SAFEARRAY->LIST MaxP)
    	lst  (MAPCAR (FUNCTION (LAMBDA (x)
    				 (VLAX-CURVE-GETPARAMATPOINT
    				   lw
    				   (VLAX-CURVE-GETCLOSESTPOINTTO lw x)
    				   )
    				 )
    			       )
    		     (LIST minp
    			   (LIST (CAR minp) (CADR MaxP))
    			   MaxP
    			   (LIST (CAR MaxP) (CADR minp))
    			   )
    		     )
    	)
      (IF (OR (<= (CAR lst) (CADR lst) (CADDR lst) (CADDDR lst))
    	  (<= (CADR lst) (CADDR lst) (CADDDR lst) (CAR lst))
    	  (<= (CADDR lst) (CADDDR lst) (CAR lst) (CADR lst))
    	  (<= (CADDDR lst) (CAR lst) (CADR lst) (CADDR lst))
    	  )
        T
        nil
        )
      )
    Attached Files Attached Files
    Last edited by BlackBox; 2017-07-07 at 02:41 PM. Reason: New Update info; Please use [CODE] Tags

  2. #2
    100 Club
    Join Date
    2011-08
    Location
    Vadodara, India
    Posts
    147
    Login to Give a bone
    0

    Default Re: Select all and only entities within a polyline

    Might this routine cal help you.

    (defun c:fac()
    (setq mang (ssget))
    (setq ntt (ssname mang 0))
    (setq crd (entget ntt))
    (command "zoom" "o" ntt "")
    (setq pts (mapcar 'cdr (vl-remove-if-not
    '(lambda (x) (= 10 (car x))) (entget ntt))))
    (setq x01 (cadr (assoc 10 crd))) ; first point X valye
    (setq y01 (caddr (assoc 10 crd)))
    (setq ssk (ssget "_wP" pts))
    ;(command "COPY" ssk ntt "" pause pause)
    (command "zoom" "P" "")
    (command "SELECT" ssk ntt PAUSE PAUSE)
    (command "COPY" "P" PAUSE PAUSE)

    )

  3. #3
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Select all and only entities within a polyline


  4. #4
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Select all and only entities within a polyline

    I was trying to find several "inside" functions to apply to your issue bypassing the WP/CP ssget function.

    Since you are trying to test polylines I would suggest getting the vertex list and testing for inside and also using the intersectwith method to test to see if the polyline crosses the boundary.

    I think you could know.

    P=
    AutomateCAD

  5. #5
    Member
    Join Date
    2004-01
    Posts
    5
    Login to Give a bone
    0

    Default Re: Select all and only entities within a polyline

    Thank you Peter for taking the time and including the threads. I am looking at them now. they do appear to offer an alternative. Esp. the inside aspect. something like "Disregard entity if not inside" thanks again

  6. #6
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Select all and only entities within a polyline

    I have some inside functions if you need to see them.
    \
    There are others on the web too.

    P=
    AutomateCAD

Similar Threads

  1. 2014 Polyline complex entities
    By Imkie in forum AutoLISP
    Replies: 4
    Last Post: 2015-01-14, 03:10 PM
  2. Add HATCH to for entities made up of POLYLINE
    By dhiraj.motghare in forum ARX
    Replies: 0
    Last Post: 2010-02-10, 11:59 AM
  3. Select entities off the screen
    By bweir in forum AutoLISP
    Replies: 5
    Last Post: 2007-04-20, 09:14 PM
  4. Can't select entities
    By jpaulsen in forum AutoCAD General
    Replies: 6
    Last Post: 2007-04-19, 03:20 PM
  5. Select entities without touching them
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2005-10-05, 12:22 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
  •