Results 1 to 2 of 2

Thread: entity selection

  1. #1
    Member
    Join Date
    2009-09
    Posts
    32
    Login to Give a bone
    0

    Default entity selection

    I want to write a program which does following

    1. I have a drawing in which each text value in the drawing is contained inside a polygon, but its not touching the polygon.

    2. Program prompts user to input a text value.

    3. After inputting the text value, the program searches the value and
    if found in the drawing it zoom to that polygon which encloses the
    specified text entity.

    I am facing problem about how to select the polygon which is enclosing the specified text value. Please give some suggestion.

    Thanks.

  2. #2
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: entity selection

    Quote Originally Posted by mdsalman2003 View Post
    I want to write a program which does following

    1. I have a drawing in which each text value in the drawing is contained inside a polygon, but its not touching the polygon.

    2. Program prompts user to input a text value.

    3. After inputting the text value, the program searches the value and
    if found in the drawing it zoom to that polygon which encloses the
    specified text entity.

    I am facing problem about how to select the polygon which is enclosing the specified text value. Please give some suggestion.

    Thanks.
    This one is very limited but hope this helps
    (almost not tested)

    Code:
    (vl-load-com)
    ; local function
    ; by Daly, Bill 
    ; http://forums.autodesk.com/t5/Visual...ht/true#M79607
    ;***************************************************************************
    ; Returns T if a point is inside the polygon bounded by an ordered list of points
    (defun IsPointInPolygon ( ptTest ptList / pt numCross ptOutside ptLast
    inside)
    (setq ptOutside (polar (getvar "EXTMAX") (/ PI 4) 1.0))
    (setq ptLast (car ptList) numCross 0)
    (foreach pt ptList
    (progn
    (if (inters ptTest ptOutside pt ptLast T)
    (setq numCross (1+ numCross))
    )
    (setq ptLast pt)
    )
    )
    (if (inters ptTest ptOutside ptLast (car ptList))
    (setq numCross (1+ numCross))
    )
    (if (= (rem numCross 2) 1)
    (setq inside T)
    (setq inside nil)
    )
    )
    ;;===============main program========================;
    (defun C:textin (/ findwhat inspoint dp plineobj points poly polyset textent
       textset textsize textstyle up)
      (setq findwhat (getstring "\nEnter text to search for: ")
     textstyle (getstring T "\n Enter textstyle: ")
     textsize  (getreal "\nEnter text size: ")
     )
      (vl-cmdf "._zoom" "_E")
      (setq textset (ssget "_X" (list (cons 0 "*TEXT")
            (cons 410 (getvar "CTAB"))
            (cons 7 textstyle)
            (cons 40 textsize)
            (cons 1 findwhat)
          ))
     )
     (if (> (sslength textset) 1)
       (progn
       (alert "More than 1 text found. Exit")
       (exit)(princ))
       (progn
         (setq textent (ssname textset 0)
        inspoint (trans (cdr (assoc 10 (entget textent))) 1 0))
       )
       )
      (setq polyset (ssget "_X" (list (cons 0 "LWPOLYLINE")
          (cons 70 1);<--closed
          )))
      (while (setq poly (ssname polyset 0))
         (setq points (vl-remove-if 'not
          (mapcar (function (lambda(x)
       (if (= 10 (car x))(cdr x))))
         (entget poly)))
        )
        (if (IsPointInPolygon inspoint points)
          (progn
     (setq plineobj (vlax-ename->vla-object
        poly))
     
        (vla-getboundingbox plineobj 'dp 'up)
     (vla-zoomwindow (vla-get-application plineobj) dp up)
     )
          )
        (ssdel poly polyset)
        )
      (princ)
      )
    ~'J'~

Similar Threads

  1. Replies: 6
    Last Post: 2012-05-01, 07:40 PM
  2. Sub entity slection within a selection set?
    By voigtmark in forum AutoLISP
    Replies: 5
    Last Post: 2010-03-02, 05:29 PM
  3. Getting "Invalid Entity Name" for Selection Set
    By mgore in forum VBA/COM Interop
    Replies: 1
    Last Post: 2008-10-30, 09:10 PM
  4. Add last entity created to selection set
    By cgerhardt in forum VBA/COM Interop
    Replies: 2
    Last Post: 2006-11-16, 08:36 PM
  5. Proxy Entity Code 310 to Normal Entity
    By KevinBarnett in forum AutoCAD General
    Replies: 2
    Last Post: 2005-05-26, 07:21 AM

Posting Permissions

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