Jump to content

Recommended Posts

Posted

I'm trying to delete 2 objects (green line and length labeled text. The window needs to be at the same angle as the green line using npt1, npt2, pt3, pt4. I can get the start (pt1) and end (pt2) points and angle (ang) of the green line. I tried using

SSGET "C" pt1 pt2

at the midpoint of the line, but the selection window is a non-rotated box capturing too many entities in the area around the green line. I know how to modify existing points of entities...I.E. a rectangle, but not how to transfer that process to points for future use. I made an attempt at modifying the X & Y values of the (2) two known points (pt1 & pt2), but it didn't work. Am I crazy to use this approach to delete the (2) two objects, or is there a better way?

 

Selection window.jpg

 

Thanks for any help,

Mike

Posted

Hi Mike,

 

The ssget Crossing mode string will use a crossing window aligned with the WCS axes, with corners located at the two given points - unfortunately, this crossing window will not be aligned with the active UCS and hence cannot be rotated.

 

Using the points as labelled in your image, you could use a Crossing Polygon selection to collect the line & text entities, e.g.:

(ssget "_CP" (list npt1 npt2 pt4 pt3) '((0 . "LINE,TEXT")))

Note that the above assumes that the points are expressed relative to the active UCS (as required by ssget) and that the objects to be selected are visible on-screen at the time of selection (this is required for any ssget graphical selection method).

 

Ideally, the objects to be selected would reside on their own distinct layer, or possess properties which could distinguish them from other objects in the drawing - this way, you could use the ssget "X" mode string to iterate over the drawing database with an appropriate filter list to retrieve the required entities without interference from surrounding objects located near or within the selection window, and the selection would not be dependent on the position of the drawing area at the time of selection.

Posted

Hello Again Lee,

Glad to see one of the great ones on here respond and help me. Many thanks.

So how do I take the (2) two original pts and add values to each of them to create the (4) four new points? I tried adding -1.0 to pt1, moving it to the lower left of itself, but I just got the negative of the X value. I'm pretty sure I need to use Polar somehow.

 

Any help would be so good. I have old 2005 routines I'm rewriting for 2014, and have a very large cadd users group waiting on me.

 

Again, thanks

Cheers, Mike

 

FYI...my wife is English...from Surrey. We're coming o England in Oct for her sisters wedding. So looking forward to seeing the English countryside again. Breathtaking.

 

Hi Mike,

 

The ssget Crossing mode string will use a crossing window aligned with the WCS axes, with corners located at the two given points - unfortunately, this crossing window will not be aligned with the active UCS and hence cannot be rotated.

 

Using the points as labelled in your image, you could use a Crossing Polygon selection to collect the line & text entities, e.g.:

(ssget "_CP" (list npt1 npt2 pt4 pt3) '((0 . "LINE,TEXT")))

Note that the above assumes that the points are expressed relative to the active UCS (as required by ssget) and that the objects to be selected are visible on-screen at the time of selection (this is required for any ssget graphical selection method).

 

Ideally, the objects to be selected would reside on their own distinct layer, or possess properties which could distinguish them from other objects in the drawing - this way, you could use the ssget "X" mode string to iterate over the drawing database with an appropriate filter list to retrieve the required entities without interference from surrounding objects located near or within the selection window, and the selection would not be dependent on the position of the drawing area at the time of selection.

Posted

So how do I take the (2) two original pts and add values to each of them to create the (4) four new points? I tried adding -1.0 to pt1, moving it to the lower left of itself, but I just got the negative of the X value. I'm pretty sure I need to use Polar somehow.

 

Check this out and let me know .

 

(defun Rectangle (p1 p2 / p3 p4 p5 p6 a h d)
 (if (setq h  (/ (setq d (distance p1 p2)) 10.)
           p3 (polar p1 (+ (setq a (angle p1 p2)) (* pi 0.5)) (/ h 2.))
           p4 (polar p3 a d)
           p5 (polar p4 (+ a (* pi 1.5)) h)
           p6 (polar p5 (+ a pi) d)
     )
   (command "_.pline" "_non" p3 "_non" p4 "_non" p5 "_non" p6 "_c")
 )
 (princ)
)

 

Usage of the above code .

 

(Rectangle p1 p2)

Posted
So how do I take the (2) two original pts and add values to each of them to create the (4) four new points? I tried adding -1.0 to pt1, moving it to the lower left of itself, but I just got the negative of the X value. I'm pretty sure I need to use Polar somehow.

 

Indeed, the polar function would likely be the easiest method to calculate the points.

Consider the following diagram & code and note how the variables correspond the to diagram:

polardiagram.png

(setq d1   0.1
     d2   0.5
     ang  (angle pt1 pt2)
     dis  (distance pt1 pt2)
     90d  (/ pi 2.0)
     npt1 (polar pt1 (- ang 90d) d1)
     npt2 (polar pt2 (- ang 90d) d1)
     npt3 (polar pt2 (+ ang 90d) d2)
     npt4 (polar pt1 (+ ang 90d) d2)
)
(ssget "_CP" (list npt1 npt2 npt3 npt4) '((0 . "LINE,TEXT")))

FYI...my wife is English...from Surrey. We're coming o England in Oct for her sisters wedding. So looking forward to seeing the English countryside again. Breathtaking.

 

Excellent - I'm sure you'll enjoy it here :)

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...