Results 1 to 4 of 4

Thread: Combined ENTSEL / INSERT (with OSNAP) tool

  1. #1
    Member
    Join Date
    2005-06
    Posts
    10
    Login to Give a bone
    0

    Default Combined ENTSEL / INSERT (with OSNAP) tool

    Hello,

    I am trying to create a one-click entity selection and block insertion solution with AutoLISP.

    The tool is supposed to detect the layer of a line and change the active layer to a different (already existing) layer based on this selection. Then it should insert a block on that newly actived layer on a sepcific point on the line.

    I want to combine these two steps into one, i.e. I want to be able to 'hover' over the line with an active OSNAP in such a way that the line gets detected (highlighted) and the selected OSNAP detects the desired block insertion point. Once the cursor is in a spot where these two selection methods are activated, the click should invoke the layer change and the block insertion at the OSNAP point.

    I have the following problems:

    1) I can detect the current line layer with ENTSEL and switch layers, but ENTSEL ignores OSNAP settings and records the actual click location. Hence I have to explicitely activate an OSNAP (e.g. endpoint) before the selection, ENTSEL will then return the correct point. However, I would like to avoid having to manually activate an OSNAP in the process.

    2) Let's say I have multiple lines sharing one endpoint (like a 'Mercedes' star) - based on my use case, this is the most likely scenario. When I click them individually (without the OSNAP), ENtSEL will return the correct entity list entry for each line. However, I noticed that when I combine the selection with an OSNAP for that common endpoint, I get the correct point locations, but every line selection also returns the same entity list entry, regardless of which line I select.

    In other words, if three lines (entities "A", "B", and "C") share the coordinate 0,0,0 with one endpoint:

    - ENTSEL without OSNAP returns "A", "B", and "C", but (obviously) different coordinates (cursor locations).
    - ENTSEL with OSNAP returns the coordinate 0,0,0 for all three lines, but also the same entity name (e.g. "A", "A", and "A")

    I haven't really investigated how it is determined which entity name is returned in the second case. When I use the BREAK command (similar functionality) that way to break one of two intersecting lines (with an intersection OSNAP activated), AutoCAD always ends up breaking the one in front (in draw order), regardless of which line I hover over. I'm not sure if it would actually help me to know anyway, because it still doesn't tell me which entity was originally selected...

    I wouldn't mind having to use a little workaround in my code (let's say to change the draw order of the selected item or to add and later delete a 'helper' entity, or something like that), but at this point I can't think of any.

    Has anybody here done something like that and can point me into the right direction?

    Thank you very much in advance!

  2. #2
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    559
    Login to Give a bone
    0

    Default Re: Combined ENTSEL / INSERT (with OSNAP) tool

    One way around is pick the line near the end you want, simply compare the endpoint & startpoint distance to the selection point and swap if necessary so returns closest point evry time so no probs with picking multiple lines.

    Code:
    (SETQ TP1 (entsel "\nSelect inside wall near left end: "))
      (setq tpp1 (entget (car tp1)))
      (setq clay (cdr (assoc 8 tpp1)))
      (setq p1 (cdr (assoc 10 tpp1)))
      (setq p2 (cdr (assoc 11 tpp1)))
      (setq p3 (cadr tp1))
      (setq ht (cdr (assoc 40 tpp1)))
      (setq el (caddr p1))
    
      (setq d1 (distance p1 p3))
      (setq d2 (distance p2 p3))
        (if (> d1 d2)
        (progn
        (setq temp p1)
        (setq p1 p2)
        (setq p2 temp)
        )

  3. #3
    Member
    Join Date
    2005-06
    Posts
    10
    Login to Give a bone
    0

    Default Re: Combined ENTSEL / INSERT (with OSNAP) tool

    Thank you, BIG-AL!

    I probably should have mentioned that I will have to do this with polylines as well - but I got the idea (and I love it)!


    Regards,
    raddxs

  4. #4
    All AUGI, all the time
    Join Date
    2003-07
    Posts
    559
    Login to Give a bone
    0

    Default Re: Combined ENTSEL / INSERT (with OSNAP) tool

    You can pick a pline and get the two vertices making up the section of the pline. It was something simple I think I got it from www.lee-mac.com

    Found this Curve.GetParameterAtPoint() to get the index of the vertex/segment that was picked based on the pick point.

    I know I did something but can not find.
    Last edited by BIG-AL; 2017-12-13 at 11:04 AM.

Similar Threads

  1. Entsel & SSGet combined
    By JaCAD in forum AutoLISP
    Replies: 10
    Last Post: 2012-10-24, 06:19 PM
  2. Creating a tool pallette with 2D blocks and 3D parts combined
    By solarsupplies in forum AMEP General
    Replies: 2
    Last Post: 2010-03-23, 04:18 PM
  3. HELP! Lost Osnap markers and tool tips...
    By woodyp in forum AMEP General
    Replies: 5
    Last Post: 2010-01-02, 03:46 AM
  4. can't insert into tool pallete
    By rbaker.147950 in forum AutoCAD Customization
    Replies: 2
    Last Post: 2008-05-01, 01:17 AM
  5. Replies: 5
    Last Post: 2007-04-26, 07:19 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •