Jump to content

Problem when selecting by window.


Hickoz_bro

Recommended Posts

Hi all,

 

I've got a problem selecting items by window in my LISP code.

 

If you take a look at the image below I've got a label who's bottom left corner is at Point 0,0, and the top right corner is at some other point (say 1000,250).

 

I want my LISP to select and hatch all items WITHIN the boundary box of this label, i.e. I don't want the boundary box selected.

 

1-07-20118-03-46AM.jpg

 

The problem is that if my label is too big (say 5000,1250) then the selection method I've used will also select the boundary box.

 

As you can see in the code below, I'm selecting using a window from 1,1 (just inside bottom left corner) to 9999,9999 (way outside the top right corner of the label). This works fine if the label is smaller, but it doesn't work on very large labels.

 

(command "-hatch" "a" "h" "y" "a" "y" "" "s" "w" "1,1" "9999,9999" "" "")

 

Is there a way to ignore the zoom factor when selecting by a window, or is there another selection method that will give me the result I want?

 

Cheers

Link to comment
Share on other sites

Perhaps use the ssget function with a selection filter to exclude the boundary object. However, this assumes the boundary object has some distinguishing characteristics to tell it apart from the other objects.

Link to comment
Share on other sites

Maybe this way .... :)

 

(vl-load-com)
(defun c:Test (/ ss l sset)
 ; Tharwat 01. 07. 2011
 (if (setq ss (ssget "_w"
                     '(1.0 1.0)
                     '(9999.0 9999.0)
                     '((0 . "*POLYLINE"))
              )
     )
   (repeat
     (setq l (sslength ss))
      (setq sset (ssname ss (setq l (1- l))))
      (if (vlax-curve-isclosed sset)
        (command "_.-hatch" "_s" sset "" "_p" "_solid" "")
      )
   )
   (princ)
 )
 (princ)
)

 

Tharwat

Link to comment
Share on other sites

Perhaps this one is better than the first one , it has a very odd option and I think it is used by anyone :D

 

(vl-load-com)
(defun c:Test (/ ss i l sset)
; Tharwat 01. 07. 2011
 (if (setq ss (ssget "_w"
                     '(1.0 1.0)
                     '(9999.0 9999.0)
                     '((0 . "*POLYLINE"))
              )
     )
   (progn
     (setq i (sslength ss))
     (repeat
       (setq l (sslength ss))
        (setq sset (ssname ss (setq l (1- l))))
        (if (vlax-curve-isclosed sset)
          (command "_.-hatch" "_s" sset "" "_p" "_solid" "")
        )
        (if (eq i (+ l 1))
          (entdel (entlast))
        )
     )
   )
   (princ)
 )

 (princ)
)

 

Tharwat

Link to comment
Share on other sites

Thanks for the suggestions guys... We ended up selecting the border only, changing the layer (we were going to do this later anyway), then turning that layer off and selecting the rest (the text items), and hatching that, then turning the border layer back on...

 

Nice and simple, and it seems to work quite well.

 

The geometry will change with each label, but it's predictable as it is the output of an Inventor VBA Macro, so I'm happy enough with this solution.

 

Thanks again.

Link to comment
Share on other sites

Nice and simple, and it seems to work quite well.

 

The geometry will change with each label, but it's predictable as it is the output of an Inventor VBA Macro, so I'm happy enough with this solution.

 

Thanks again.

 

You're welcome Gerrard .

 

I am also happy that you got it work with that manipulating idea with Hatch entity . :)

 

Regards.

 

Tharwat

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...