Hi all,
I am attempting to make a selection-set of all entities within the bounding box of all entities on a specific layer.
I know that sounds confusing so I'll try to explain. I need to get the bounding box of my border & use it with ssget to select all blocks while ignoring all blocks outside of my border.
I have having trouble feeding the bounding box points to the ssget function. What am I doing wrong?
(AND (SETQ BLST (LIST "BUZZTOP" "CANISTER1" "FUSECANISTER2" "MDXR3" "NOZZLE" "P3" "PP" "StepNozzle" "VENTURISKIMMER2") SS (SSADD) S (SSGET "x" '((8 . "BORDER"))) ) (VLA-GETBOUNDINGBOX (VLAX-ENAME->VLA-OBJECT (SSNAME S 0)) 'LL 'UR) (SETQ LL (VLAX-SAFEARRAY->LIST LL) UR (VLAX-SAFEARRAY->LIST UR) SS1 (SSGET "B" 'LL 'UR (LIST '(0 . "insert") (CONS 2 (STRCAT "`*U*" BLST)) '(410 . "Model"))) ) )
Thanks in advance for any help.
Solved! Go to Solution.
Solved by Lee_Mac. Go to Solution.
Solved by hmsilva. Go to Solution.
Hi mid-awe,
perhaps something like this
(AND (SETQ BLST ",BUZZTOP,CANISTER1,FUSECANISTER2,MDXR3,NOZZLE,P3,PP,StepNozzle,VENTURISKIMMER2l" SS (SSADD) S (SSGET "x" '((8 . "BORDER") (410 . "Model"))) ) (VLA-GETBOUNDINGBOX (VLAX-ENAME->VLA-OBJECT (SSNAME S 0)) 'LL 'UR) (SETQ LL (VLAX-SAFEARRAY->LIST LL) UR (VLAX-SAFEARRAY->LIST UR) SS1 (SSGET "w" LL UR (LIST '(0 . "insert") (CONS 2 (STRCAT "`*U*" BLST)) '(410 . "Model"))) ) )
Henrique
Should work, I did change the "B" mode to "W"...
Try this one
(AND (SETQ BLST ",BUZZTOP,CANISTER1,FUSECANISTER2,MDXR3,NOZZLE,P3,PP,StepNozzle,VENTURISKIMMER2" SS (SSADD) S (SSGET "x" '((8 . "BORDER") (410 . "Model"))) ) (VLA-GETBOUNDINGBOX (VLAX-ENAME->VLA-OBJECT (SSNAME S 0)) 'LL 'UR) (SETQ LL (VLAX-SAFEARRAY->LIST LL) UR (VLAX-SAFEARRAY->LIST UR)) (vl-cmdf "_.zoom" "_W" LL UR) (setq SS1 (SSGET "_W" LL UR (LIST '(0 . "insert") (CONS 2 (STRCAT "`*U*" BLST)) '(410 . "Model")))) (vl-cmdf "_.zoom" "_P") )
Henrique
Hi mid-awe,
The following is untested, but may help:
(defun c:test ( / app bor llp lst sel str urp ) (setq lst '("BUZZTOP" "CANISTER1" "FUSECANISTER2" "MDXR3" "NOZZLE" "P3" "PP" "StepNozzle" "VENTURISKIMMER2") str (apply 'strcat (mapcar '(lambda ( x ) (strcat "," x)) lst)) app (vlax-get-acad-object) ) (if (setq bor (ssget "_X" '((8 . "BORDER") (410 . "Model")))) (progn (vla-getboundingbox (vlax-ename->vla-object (ssname bor 0)) 'llp 'urp) (vla-zoomwindow app llp urp) (if (setq sel (ssget "_C" (trans (vlax-safearray->list urp) 0 1) (trans (vlax-safearray->list llp) 0 1) (list '(0 . "INSERT") (cons 2 (strcat "`*U*" str)) '(410 . "Model") ) ) ) (sssetfirst nil sel) (princ "\nNo objects found within border.") ) (vla-zoomprevious app) ) (princ "\nBorder not found in Modelspace.") ) (princ) ) (vl-load-com) (princ)
Thank you Lee,
That did it. Please, help me understand why yours works and Henrique and I got nil. (that's not fair of me 😉 Henrique tried to fix my mess.)
As I work your sample into my main program, I found that I did not work without the:
(vla-zoomwindow app llp urp)
part. It seems that just makes sure that the border is entirely visible before selecting it. I still don't understand it because I was zoomed out a little more than necessary when running the junky version. Also,
(TRANS (VLAX-SAFEARRAY->LIST URP) 0 1)
Shouldn't make a difference, unless I'm not in WCS? Right?
@mid-awe wrote:
... bounding box points return as:
((-1.0e-008 -1.00001e-008 -1.0e-008) (1584.0 996.0 1.0e-008))
It's unrecognizable to me, maybe someone can determine the issue. Is that point list good? I'm not sure what I'm looking at there.
Parts of that are in scientific notation. The e stands for exponent, applied to 10. So 1.0e-008 means 1 times 10 to the minus-8 power, which is pretty darned close to zero. You sometimes get that kind of result with calculated points. It shouldn't affect the working of the routine, unless you have some things mighty close to the edge of the border, so that parts of them fall within that tiny tolerance of difference between the bounding box window and the actual outline, which doesn't seem likely in any actual drawing situation.
@mid-awe wrote:
Henrique, Thank you, but it still comes up nil. Lee's sample works, now I hope he has time to shed some light on it for me.
Hi mid-awe,
I did add a zoom window to ensure the blocks visibility before performing the selection window, so it should select all blocks inside the border...
Henrique
Thank you Lee,
That did it. Please, help me understand why yours works and Henrique and I got nil. (that's not fair of me 😉 Henrique tried to fix my mess.)
As I work your sample into my main program, I found that I did not work without the:
(vla-zoomwindow app llp urp)
part. It seems that just makes sure that the border is entirely visible before selecting it. I still don't understand it because I was zoomed out a little more than necessary when running the junky version.
As you've probably gathered, the graphical selection methods will only select objects visible on screen - this even applies to block components, as the following animation demonstrates:
I have noted this subtle behaviour in my ssget function reference, where applicable.
(TRANS (VLAX-SAFEARRAY->LIST URP) 0 1)
Shouldn't make a difference, unless I'm not in WCS? Right?
Correct - ssget accepts UCS points, the getboundingbox method returns points in WCS.
You're most welcome mid-awe.