Ssget filter for a line

Discussion in 'AutoCAD' started by Joe Fields, Mar 25, 2005.

  1. Joe Fields

    Joe Fields Guest

    I am using this routine to insert different blocks onto the ends of lines and it will modify the block to be at the angle of the line, change it to the same layer, and trim the line if need be. The problem I have been having is when it inserts a block that has an entity that passes through the insertion point and I believe that it is running into an error at the ssget because it is picking the block instead of the line. Iif I add the ssget filter '((0 . "LINE")) the routine doesn't work at all. How else can I aquire the entity info on the line using ssget and and the filter for lines?

    Thanks in advance,
    Joe Fields

    (defun c:attach_end (/)
    (setq block (entlast))
    (setq block_info (entget block))
    (setq line1 (ssget ins_point '((0 . "LINE"))))
    (setq line (ssname line1 0))
    (setq line_info (entget line))
    (setq line1a (cdr (assoc 10 line_info)))
    line1b (cdr (assoc 11 line_info)))
    (setq new_layer (cdr (assoc 8 line_info)))
    (if (<= (distance line1a ins_point) (distance line1b ins_point))
    (setq line_angle (angle line1a line1b)
    line_end line1a)
    (setq line_angle (angle line1b line1a)
    line_end line1b)
    )
    (entmod (subst (cons 8 new_layer) (assoc 8 block_info)
    (subst (cons 50 line_angle) (assoc 50 block_info)
    block_info)))
    (entupd block)

    ;; If it is a riser, trim the end of the line to the edge of the block

    (if (= (cdr (assoc 2 block_info)) "p_riser_end")
    (progn
    (setq dist (/ (getvar "dimscale") 16))
    (if (= line_end line1a)
    (entmod (subst (cons 10 (polar line1a line_angle dist)) (assoc 10 line_info) line_info))
    (entmod (subst (cons 11 (polar line1b line_angle dist)) (assoc 11 line_info) line_info))
    )
    (entupd line)
    )
    )
    )
     
    Joe Fields, Mar 25, 2005
    #1
  2. Joe Fields

    Paul Turvill Guest

    Where is ins_point defined?
    ___
     
    Paul Turvill, Mar 25, 2005
    #2
  3. Joe Fields

    Paul Turvill Guest

    Or ... assuming ins_point is a global variable, and therefore a valid point,
    try this:
    (setq line1 (ssget "C" ins_point ins_point '((0 . "LINE"))))
    ___
     
    Paul Turvill, Mar 25, 2005
    #3
  4. Joe Fields

    Joe Fields Guest

    oh I think the ins_point code got deleted from the first post when I was hacking out some commented out lines. Here is where I defined it:

    (setq ins_point (osnap (cdr (assoc 10 block_info)) "_end"))

    I added your suggestion to the ssget and it appears to be working quite well now. I still don't quite understand why the original code wasn't working. It sounds pretty logical when you want to do an ssget from anything passing through a point and you want to filter the selection set but who knows sometimes.

    Thanks for your help Paul

    Joe Fields
     
    Joe Fields, Mar 25, 2005
    #4
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.