+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 20 of 20
  1. #11
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    2,997

    Default

    Registered forum members do not see this ad.

    This will select all instances of said border block. Is it unique in the current tab?
    Code:
    (ssget "_X" (list '(0 . "INSERT") (cons 410 (getvar "CTAB")) '(2 . "ROBERT")))
    Next look to SSNAME, ENTGET and ASSOC functions.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  2. #12
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,943

    Default

    ... Hope that's not a dynamic block.
    "Potential has a shelf life." - Margaret Atwood

  3. #13
    Super Member irneb's Avatar
    Computer Details
    irneb's Computer Details
    Operating System:
    Win7 Pro 64bit
    Computer:
    Antec One Hundred
    Motherboard:
    ASUS P8P67-Pro P67
    CPU:
    Intel i7 2600 @ 3.4GHz
    RAM:
    16GB-1600MHz
    Graphics:
    GeForce GT 430 (1GB)
    Primary Storage:
    Seagate1TB SATA2 - 7200rpm
    Monitor:
    Samsung 2333TN 23" 1920 x 1080 Full HD LCD Monitor2GW
    Discipline
    Architectural
    irneb's Discipline Details
    Occupation
    Architectural Technician and Programmer
    Discipline
    Architectural
    Using
    AutoCAD 2013
    Join Date
    Sep 2010
    Location
    Jo'burg SA
    Posts
    1,634

    Default

    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!

  4. #14
    Forum Newbie
    Using
    AutoCAD 2011
    Join Date
    Jul 2012
    Posts
    8

    Default

    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

  5. #15
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,943

    Default

    Quote Originally Posted by kycu View Post
    This is not a dynamic block, and for sure there is only one block on each sheet with this name.
    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

  6. #16
    Forum Newbie
    Using
    AutoCAD 2011
    Join Date
    Jul 2012
    Posts
    8

    Default

    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

  7. #17
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,943

    Default

    Quote Originally Posted by kycu View Post
    Beautifull!

    This is exactly what i need
    No worries; happy to help.

    Quote Originally Posted by kycu View Post
    Now i need to study each line to understand the code ... for sure it wont be easy ...
    Code revised here, and I've added some comments.
    "Potential has a shelf life." - Margaret Atwood

  8. #18
    Forum Newbie
    Using
    AutoCAD 2011
    Join Date
    Jul 2012
    Posts
    8

    Default

    Thank you very much!

    Could you recomend any tutorial (beginners level) for Autolisp that i could learn step by step about Autolisp?

  9. #19
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,943

    Default

    Twice in one day....

    Quote Originally Posted by RenderMan View Post

    There are tons of resources to learn from for free such as forums like these, AfraLisp, etc., however, if you want a good book I'd recommend (image is linked):

    The Visual LISP Developer's Bible


    "Potential has a shelf life." - Margaret Atwood

  10. #20
    Forum Newbie
    Using
    AutoCAD 2011
    Join Date
    Jul 2012
    Posts
    8

    Default

    Registered forum members do not see this ad.

    Thanks so much once again!

Similar Threads

  1. I have to shift-select to select multiple objects
    By PDS in forum AutoCAD Beginners' Area
    Replies: 16
    Last Post: 29th Nov 2011, 08:15 pm
  2. Select By Selection Set Name, on 'Select Objects:' prompt
    By harilalmn in forum AutoLISP, Visual LISP & DCL
    Replies: 15
    Last Post: 23rd Aug 2011, 10:28 am
  3. Use Quick Select to select objects in your AutoCAD drawing
    By AutoCAD Tips Blog in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 16th Mar 2011, 04:29 pm
  4. Fix some elements' size
    By Bane in forum AutoCAD General
    Replies: 0
    Last Post: 12th Mar 2009, 06:50 pm
  5. Quickly select objects with Quick Select
    By AutoCAD Tips Blog in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 23rd Dec 2007, 01:13 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts