Selecting object inside of insert

Discussion in 'AutoCAD' started by Don Butler, Oct 21, 2004.

  1. Don Butler

    Don Butler Guest

    I have an interesting situation.

    I have a block which is a pipe fitting. Let's say it's a tee with three
    branches.

    The insertion point of the block is the intersection of the three branches.

    At the end of each branch is a 3DSOLID (Sphere).

    Branch 1
    o Sphere
    |
    |
    |--------o Branch 3
    |
    |
    o Sphere
    Branch 2

    Each sphere has a particular volume that I use to determine the pipe size
    that should connect to it.

    So here's my problem:

    What is the best way to retrieve the sphere object within the insert?

    The only way I know how to do it is as below
    ....
    (setq ss (ssget ":N:D" (list (cons 0 "INSERT"))))
    (setq lis (ssnamex ss) lis2 '())
    ....
    I'd rather osnap to the center of the sphere, so it's easy to select, and
    somehow use the pickpoint.

    Anyone have any ideas?

    Thanks alot,

    Don
     
    Don Butler, Oct 21, 2004
    #1
  2. Don Butler

    James Allen Guest

    Hi Don,

    You can use osnap (center in this case) when responding to (nentselp).
     
    James Allen, Oct 21, 2004
    #2
  3. Don Butler

    James Allen Guest

    Watch out though if you are working in 3D. If the point does not lie in the
    current ucs plane, you may get an unexpected point using this. If this is
    the case I think you can get around it, but it will be a little more work.

    James
     
    James Allen, Oct 21, 2004
    #3
  4. Don Butler

    Don Butler Guest

    Thanks James,

    The problem is that there may be other objects residing at that point, in
    this case construction lines.

    Maybe I can get an ssget "c" and hide all objects but the insert and then
    try nentselp again.

    Seems like a lot of work though given that AutoCAD finds the sphere easily
    with the Center osnap.

    What I'd REALLY like to know is how AutoCAD finds the sphere.

    Oh well, maybe we'll never know... :)

    Don
     
    Don Butler, Oct 21, 2004
    #4
  5. Don Butler

    Don Butler Guest

    Actually, I am working in 3D.
    The tee shown in my original post is is part of a 3D fitting. It's a
    skeleton of sorts within the fitting.
    The actual fitting skin is composed of 3D faces which are on a layer that is
    turned off while the fitting is placed.
    For final visualization and rendering the layer is turned back on.

    The way the routine works is that the user selects a fitting via dialog and
    it "AutoSnaps" to construction lines with automatic UCS alignment.
    The user later draws a center line from sphere to sphere (end of fitting to
    end of fitting).
    The program evaluates the pipe size based on the sphere and the draws a 3D
    cylinder between the two.

    Thanks,

    Don
     
    Don Butler, Oct 21, 2004
    #5
  6. Don Butler

    T.Willey Guest

    Here is how I would do it.

    (setq ent1 (nentsel "\n Select solid: "))
    (setq ent1 (vlax-ename->vla-object (car ent1)))
    (setq cpt1 (vlax-get ent1 'Centroid))
    (setq vol1 (vlax-get ent1 'Volume))

    Hope that helps.
    Tim
     
    T.Willey, Oct 21, 2004
    #6
  7. Don Butler

    James Allen Guest

    Good point. I use ctrl selection (cycling) alot, but have been frustrated
    that it does no good for overlapping nested items. Tim's solution looks
    good to me.

    James
     
    James Allen, Oct 21, 2004
    #7
  8. Don Butler

    Don Butler Guest

    What I wound up doing is really convoluted.

    1. Command UNDO Mark
    2. Select center points of spheres at fittings A and B
    3. Build SS of objects found at center points with (ssget "C"
    4. Filter SS's for INSERTS
    5. Explode Inserts
    6. Build SS's of objects found at center points with (ssget "C"
    7. Filter SS's for 3DSOLIDS
    8. Get volumes and bind to variables
    9. Command UNDO Back
    10. If everything is cool... remainder of routine...

    WOW!

    :)

    Don
     
    Don Butler, Oct 21, 2004
    #8
  9. Don Butler

    Don Butler Guest

    Thanks

    Don

     
    Don Butler, Oct 21, 2004
    #9
  10. Don Butler

    T.Willey Guest

    You're welcome.

    Tim
     
    T.Willey, Oct 21, 2004
    #10
  11. Don Butler

    James Allen Guest

    Don, does this seem any better to you?

    (defun GetCnxnInfo (/ p1 p2 sslst info)
    (setq p1 (getpoint "\nPick first connection center point. ")
    p2 (getpoint "\nPick second connection center point. ")
    )
    ;; Get a sset which includes the 'picked' inserts
    (ssget "c" p1 p2 '((0 . "INSERT")))
    (vlax-for obj (vla-get-ActiveSelectionset
    (vla-get-ActiveDocument (vlax-get-acad-object))
    )
    (setq sslst (append sslst (vlax-invoke obj 'Explode)))
    )
    ;; Extract the desired info from the connections
    (foreach obj sslst
    (if (eq (vla-get-ObjectName obj) "AcDb3dSolid")
    (mapcar
    '(lambda (a)
    (if (and (not (assoc a info))
    (equal (vlax-get obj 'Centroid) a 1e-6)
    )
    (setq info (cons (cons a (vla-get-Volume obj)) info))
    )
    )
    (list p1 p2)
    )
    )
    ;;Clean up after explosion
    (vla-Delete obj)
    )
    info
    )

    The explode portion would need a little adjustment if you might have NUS
    blocks. Not having seen your code, this may actually be longer code-wise,
    but reduces the non-processing operations to getpoint, getpoint, ssget,
    vla-explode, delete. Maybe not much reduction, but I would feel better not
    disturbing existing objects to remain and avoiding multiple ssget calls.
    This is another situation where a true 'nssget' would be wonderful, but I
    haven't seen one yet.

    James
     
    James Allen, Oct 22, 2004
    #11
  12. Don Butler

    Don Butler Guest

    Thanks James,

    I will look at it. I'm sure ActiveX will be more efficient.

    Don
     
    Don Butler, Oct 25, 2004
    #12
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.