Results 1 to 4 of 4

Thread: Help relating to selection and selection sets

  1. #1
    Member
    Join Date
    2003-12
    Posts
    47
    Login to Give a bone
    0

    Default Help relating to selection and selection sets

    1) What is the function to use in order to return only the subentity of a complex object?
    For eg, if you pick a polyline, it will return the line data at the pick point.

    2) Is it possible to use ssget and its filter list to create a selection set of all objects crossing and inside the polygon and if the object is a complex object, it returns only the subentities within the crossing polygon?

    Thanks.

    csgoh

  2. #2
    100 Club
    Join Date
    2000-12
    Posts
    126
    Login to Give a bone
    0

    Default Re: Help relating to selection and selection sets

    Csgohjmj,
    1) What kind of complex objects are you referring to? For polylines, only old style polylines such as 3dmeshes and 3dpoly's are considered complex objects. Lightweight polylines don't have subentities. If the line data is merely a matter of vertices then there's an example of retrieving line data here, - look for the function getSegment.

    2) Yes, it's possible. I believe there was a thread on polylines used as WP or CP selection on this forum. But again, what kind of complex objects are you looking to return. Is it vertices of old style polylines or block subents?

  3. #3
    Member
    Join Date
    2003-12
    Posts
    47
    Login to Give a bone
    0

    Default Re: Help relating to selection and selection sets

    Hi Stig;
    I am actually referring to 3dpolylines and lwpolylines.
    Thanks.

    csgoh

  4. #4
    100 Club
    Join Date
    2000-12
    Posts
    126
    Login to Give a bone
    0

    Default Re: Help relating to selection and selection sets

    Okie

    1) The getSegment function mentioned above will get segment data from both 2D and 3D polylines. I take it that with "line" data you mean vertices comprising a segment?

    2) When you say subentities within the crossing polygon, which data are you interested in? If it is merely vertices of 3Dpoly's and lwpoly's then this might get you started:

    getCoordinates is a simple example of extracting coordinates from both kinds of polylines (I'm sure there are cleaner and faster methods out there than this)

    crossPolygon will use a polyline as a CP selection by calling getCoordinates and pass the coordinates to an SSGET "_CP" function. Beware that self-intersecting polylines will always cause SSGET to return nil.

    C:INPOLY will call crossPolygon to get a selection set and run through each member. If a member is a polyline, it'll call getCoordinates to extract the coordinates. The return value is a list of coordinates lists of plines found within the pline. Is that what you're after?

    If at all usable then take what you can use, or at least add some error handling. These are just quickly written samples of some generic ideas without much error handling.

    Code:
    (defun getCoordinates (obj / coords coordlst objname)
      (defun getCoords (obj)
        (vlax-safearray->list
          (vlax-variant-value (vla-get-coordinates obj))))
    
      (cond ((member (setq objname (vla-get-objectName obj))
                     '("AcDb3dPolyline" "AcDbPolyline"))
             (setq coordlst (getCoords obj))
             (while coordlst
               (cond ((= objname "AcDb3dPolyline")
                      (setq coords   (cons (list (car coordlst) (cadr coordlst)
                                                 (caddr coordlst)) coords)
                            coordlst (cdddr coordlst)))
                     ((setq coords   (cons (list (car coordlst) (cadr coordlst)) coords)
                            coordlst (cddr coordlst)))
               )
             )
            )
      )
      (reverse coords)
    )
    
    (defun crossPolygon (/ ent vertices sset)
      (and (setq ent (car (entsel)))
           (member (cdr (assoc 0 (entget ent))) '("POLYLINE" "LWPOLYLINE"))
           (setq vertices (getCoordinates (vlax-ename->vla-object ent)))
           (setq sset (ssget "_CP" vertices))
           (ssdel ent sset)
      )
      sset
    )
    
    (defun C:inPoly (/ lst ss a coords)
      (cond ((setq ss (crossPolygon))
             (setq a 0)
             (repeat (sslength ss)
               (if (setq coords (getCoordinates (vlax-ename->vla-object (ssname ss a))))
                 (setq lst (cons coords lst)))
               (setq a (1+ a))
             )
            )
      )
      (reverse lst)
    )
    Last edited by stig.madsen; 2004-09-17 at 03:43 PM.

Similar Threads

  1. Selection sets
    By garethace in forum DV - Tutorials
    Replies: 0
    Last Post: 2010-06-01, 09:46 AM
  2. Selection Sets
    By MikeJarosz in forum VBA/COM Interop
    Replies: 3
    Last Post: 2008-07-11, 07:56 PM
  3. ...Selection sets...
    By davidmatyas in forum VBA/COM Interop
    Replies: 15
    Last Post: 2008-04-02, 07:14 PM
  4. Too many Selection Sets
    By ccowgill in forum AutoLISP
    Replies: 8
    Last Post: 2007-03-02, 03:03 PM
  5. Selection Sets
    By hostetterkl in forum AutoLISP
    Replies: 1
    Last Post: 2005-05-17, 07:43 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
  •