... Hope that's not a dynamic block.
Registered forum members do not see this ad.
This will select all instances of said border block. Is it unique in the current tab?
Next look to SSNAME, ENTGET and ASSOC functions.Code:(ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar "CTAB")) '(2 . "ROBERT")))
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
... Hope that's not a dynamic block.
"Potential has a shelf life." - Margaret Atwood
Well, seeing a you already selected all (and with RenderMan's sample: all on current tab), then you could step through each item in the selection set (ssname), then get its ActiveX object (vlax-ename->vla-object) and check if it's a block reference (vla-get-ObjectName should equal "AcDbBlockReference"). Then you can check if the block's effective name equals "robert" (vla-get-EffectiveName). Then the block's insertion point would be available through vla-get-InsertionPoint (only you'd need to convert the variant-safearray to a list of reals for the point, or use vlax-get with 'InsertionPoint). Or of the InsertionPoint's not on the bottom-left you could use vla-GetBoundingBox. That way it should work for even a dynamic block.
If not a DB, then what Mircea shown should be fine. The reason he's asked about it being unique is that it's possible to place a 2nd copy (or more) of the block on the same tab. In such case which one should be used as the source point for the move? The 1st one, or the lowest & leftmost, or some other criteria?
Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!
Hi,
This is not a dynamic block, and for sure there is only one block on each sheet with this name.
The code that RenderMan sent works great. The only thing that i would like to add is not to choose manually left-lower corner as a point to move. Would be great if the program chooses it by himself.
Robert
Given these parameters:
Code:;; Load Visual LISP extensions (vl-load-com) (defun c:FOO2 (/ ss1 tab mn mx) ;; If there is a vlaid selection set of block(s) named "ROBERT" (if (setq ss1 (ssget "_x" (list '(0 . "INSERT") '(2 . "ROBERT") (setq tab (cons 410 (getvar 'ctab))) ) ) ) ;; Then (progn ;; Extract the bounding box (vla-getboundingbox ;; From the Vla-Object of the first item in the selection set (vlax-ename->vla-object (ssname ss1 0)) 'mn 'mx ) ;; Move (command "._move" ;; A selection set of all objects on the current tab (ssget "_x" (list tab)) "" ;; Convert the lower left point of the bounding box ;; from a safearray to a list (vlax-safearray->list mn) '(0 0 0) ) ) (prompt "\n** Nothing selected ** ") ) (princ) )
Last edited by BlackBox; 18th Jul 2012 at 08:49 pm. Reason: Code revised
"Potential has a shelf life." - Margaret Atwood
Beautifull!
This is exactly what i need
Now i need to study each line to understand the code ... for sure it wont be easy ...
Regards,
Robert
No worries; happy to help.
Code revised here, and I've added some comments.
"Potential has a shelf life." - Margaret Atwood
Thank you very much!
Could you recomend any tutorial (beginners level) for Autolisp that i could learn step by step about Autolisp?
Registered forum members do not see this ad.
Thanks so much once again!
Bookmarks