TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Brick_top on December 28, 2010, 06:02:12 AM
-
I'm trying to select an object from a selected point, I'm able to do it but only if the object is on screen
Here is the code
(defun c:bd ()
(setq pt1 (getpoint "\nPonto para detectar ilha:")
pre 0.0001
xpt1 (car pt1)
ypt1 (cadr pt1)
ss1 nil
)
(while
(if
(= (setq ss1 (ssget (list xpt1 ypt1))) nil)
(setq xpt1 (- xpt1 pre))
);if
);while
)
I'm only testing in "-x" direction.
How can I select the object if it is "off screen"?
Off Topic - Also would it be better to stop creating topics? I have three already with this one
-
Off Topic - Also would it be better to stop creating topics? I have three already with this one
I assume you mean 'three including this one'
That seems fine to me ... If they were all related to the same topic someone will probably have a little whinge though.
The topic is well named, so that will save you some grief. ;)
-
I found out that I can just zoom to extents and it will select the object with no problem.
So this is not a problem anymore
It would be interesting to see if anyone has the answer though
Thanks a lot
-
Off Topic - Also would it be better to stop creating topics? I have three already with this one
I assume you mean 'three including this one'
That seems fine to me ... If they were all related to the same topic someone will probably have a little whinge though.
The topic is well named, so that will save you some grief. ;)
Yeah that was what I meant!
My english could be better
Thanks for the clarification
-
Another way would be to use nentselp
-
I'm trying to select an object from a selected point, I'm able to do it but only if the object is on screen
Here is the code
(defun c:bd ()
(setq pt1 (getpoint "\nPonto para detectar ilha:")
pre 0.0001
xpt1 (car pt1)
ypt1 (cadr pt1)
ss1 nil
)
(while
(if
(= (setq ss1 (ssget (list xpt1 ypt1))) nil)
(setq xpt1 (- xpt1 pre))
);if
);while
)
I'm only testing in "-x" direction.
How can I select the object if it is "off screen"?
Off Topic - Also would it be better to stop creating topics? I have three already with this one
SSGET works only with object on screen , except by( ssget ¨X¨
You can do a ZOOM center point
-
My suggestion is to use something like the following (unless there is more than one object at the point):
(defun c:bd ()
(setq pt1 (getpoint "\nPonto para detectar ilha:")
pre 0.0001
xpt1 (car pt1)
ypt1 (cadr pt1)
ss1 nil
)
(while
(if
(= (setq ss1 (nentselp "" (list cpt1 ypt1)) nil)
(setq xpt1 (- xpt1 pre))
);if
);while
)
This should select items off the screen as well.
-
thats interesting, i have to look into that nentselp "" part, I don't know about.
but yeah there is one more object at that point, and that is a closed polyline. I have to check if pt1 is inside the selected closed polyline and if not select another one.
I found a routine that checks if a point is inside a closed polyline but, I'll have to understand how it works
thanks for all the help guys
-
apparently it isn't working, I typed the missing parenthesis and corrected the misspelled variable
(defun c:bd ( / ss1)
(setq pt1 (getpoint "\nPonto para detectar ilha:")
pre 0.01
xpt1 (car pt1)
ypt1 (cadr pt1)
)
(while
(if
(= (setq ss1 (nentselp "" (list xpt1 ypt1))) nil)
(setq xpt1 (- xpt1 pre))
);if
);while
)
it works if the object is onscreen
-
apparently it isn't working,
Brick_top
Do you know what that code is doing ??
-
I haven't really understood the part of the nentselp.
It is changing the value of the x coordinate until it selects an object. I wrote the code, I just don't understand the tip about the nentselp.
edit - but I guess that the user that gave the tip was trying to tell me how to select the object if it is offscreen
-
Does it select objects on screen ??
-
yes it does
I guess I can just do a zoomextents
-
I tried doing zoom extents
(defun c:bd ()
(setq pt1 (getpoint "\nPonto para detectar ilha:")
pre 0.01
xpt1 (car pt1)
ypt1 (cadr pt1)
ss1 nil
)
(command "zoom" "E")
(while
(if
(= (setq ss1 (ssget (list xpt1 ypt1))) nil)
(setq xpt1 (- xpt1 pre))
);if
);while
(command "zoom" "P")
)
But I guess this introduces some kind of precision error since it selects objects in other directions
-
yes,
Selecting objects using a point off screen has always been an issue.
regarding your code ... I'll be back is a bit ..
-
Have a play with something like this
[color=green];; bd1.lsp[/color]
(defun [color=blue]c:bd1[/color] (/ Limit Pre Pt1 Sel Xpt1 Ypt1)
(vl-load-com)
[color=green];; sample by kdub@theSwamp
;; Select an object at or in in a relative position to the selected Point.
;; If the Object is not found, change the point negative X vector 0.01
;; untill the search limit is reached
;; Will only select object if the point is ON screen.[/color]
(setq pt1 (getpoint [color=Maroon]"\nPoint to Test:"[/color])
pre 0.01
xpt1 (car pt1)
ypt1 (cadr pt1)
limit (- xpt1 15)
)
(vl-cmdf [color=Maroon]"zoom"[/color] [color=Maroon]"E"[/color])
(while (and (> xpt1 limit)
(not (setq SEL (nentselp [color=Maroon]""[/color] (list xpt1 ypt1))))
)
(setq xpt1 (- xpt1 pre))
)
(vl-cmdf [color=Maroon]"zoom"[/color] [color=Maroon]"P"[/color])
SEL
)
-
thanks a lot for your code
Unfortunately I've not been able to understand if it is working or not
It prompts me to an entity name and a coordinate of the point I picked right?
-
if I remove the vl-cmdf parts it gives me the coordinate of the object I want to select
-
Retutns the value of SEL
If it works :
returns the entity and pickpoint from nentselp
if it fails :
returns nil
//-----------------------
The entity MAY NOT be at the point selected.
Please note the selection functions return the point selected but select onjects inside the pickbox.
The example shown is using a circle with a 10.0 radius ... the selected point was (-9.87 0.0 0.0) and the circle circumference was just in the pickbox.
There are several ways to determine the actual entity point ... but will not be required if you only want the entity.
-
if I remove the vl-cmdf parts it gives me the coordinate of the object I want to select
NO !
removing the Zoom commands will just stop the point being selected if it's off screen.
-
I removed the declared variable sel to test from the command line what entity it was but it isn't the one I want
But if I remove the vl-cmdf parts it selects the entity I expect it to select, it if is on screen
-
I removed the declared variable sel to test from the command line what entity it was but it isn't the one I want
But if I remove the vl-cmdf parts it selects the entity I expect it to select, it if is on screen
Everything will work just as you expect it to, unless your expectations are incorrect.
-
But if I remove the vl-cmdf parts it selects the entity I expect it to select, it if is on screen
I will select the correct entity with the zoom commands left in ..
I removed the declared variable sel to test from the command line what entity it was but it isn't the one I want
Care to explain this in more detail. ?
Is the entity within the 'limit' distance as nominated in the code ?
(if a limit is not expressed, the code will continue untill it runs out of memory or finds something 5 kilometers away)
-
I guess I have found out what I was doing wrong
I was testing without a closed object, when I try your routine with a closed polyline it works
-
I guess I have found out what I was doing wrong
I was testing without a closed object, when I try your routine with a closed polyline it works
NO!
a closed object is NOT required.
Please don't make assumptions based on limited and possibly faulty testing ... you'll remain sane longer :)
-
but when I don't use a closed object it "doesn't select the next object in the -x direction" In case this was what it was expected to do
I'm sorry for all the trouble
-
but when I don't use a closed object it doesn't select the next object in the -x direction
I'm sorry for all the trouble
Can you post a drawing of the data you've using, and a description of what you expect.
What do you mean NEXT object ... there was never discussion of a NEXT object :|
-
I'm sorry for not being clear enough
I was trying to select the next object in the -x direction from picked point
-
Here is the drawing
-
there might be a precision error, because if I test this in a drawing with a smaller zoom extents area it works as I was expecting, which was for it to select the "next" object in the -x direction from the picked point
-
I'm not going to waste my time looking at a drawing with a couple of thousand entitys in it and no description of what you are trying to achieve.
please post a simple example of what you are trying to do.
-
This was the drawing in which I was doing the tests since I thought I didn't have to use any specific drawing to test it.
I was expecting to select the next object the routine would found in the -x direction from the picked point.
The real usage I wanted it for is already working, which as for it to select a closed polyline surrounding the picked point.
I'm really sorry if I made some confusion because of being too vague and not giving the correct information and wasting your time
-
I surpose there's a lesson there for all of us.
I'm pleased you have what you want.
//-----------
OFF TOPIC :
I don't think your client will get those cars out of the garage :-)
-
Thanks for your patience!
yeah it will be hard to get the cars out, I'm working on it still