+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Senior Member
    Computer Details
    YZ's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    CORE I7 3770 3.4GHZ
    CPU:
    Intel Duo Core E6550 @ 2.33GHz
    RAM:
    16
    Graphics:
    NVIDIA Quadro K600
    Monitor:
    LG Flatron W2343T
    Discipline
    Surveying
    YZ's Discipline Details
    Occupation
    CAD Operator and Manager; Land Survey, Civil Design
    Discipline
    Surveying
    Details
    Topographic ground surveys for architects and engineers; Land Subdivisions; Civil Engineering Design.
    Using
    AutoCAD 2017
    Join Date
    Oct 2007
    Location
    Sydney, Australia
    Posts
    463

    Default Cannot Get This Lisp To Work on All Blocks in a DWG

    Registered forum members do not see this ad.

    We are trying to write a lisp that will set all blocks in a dwg to an X, Y, and Z scale value of 1.

    By my reckoning it should work. But it only applies the scale change to one block in the dwg - the latest one that was inserted.

    Do I need to loop through the selection set? I assumed it would apply the change to all in the selection automatically.

    Thanks for any help. See below for code, and see attached a sample dwg that shows one block only changing.

    Code:
    (defun c:SCB ()
      ;(setvar "qaflags" 1)
     ;below selects all blocks 
      (setq ALLBLOCKS (ssget "X" (LIST (cons 0 "INSERT"))))
      ;(command "select" allblocks))
      (if  
            (progn
            (setq blocks (ssname ALLBLOCKS 0))
                    (entmod ; modifies the properties of the entity
                        (append ; combines the list
                            (entget blocks); indicates what entity to edit
                            (list ; create a list of properties to change
                                (cons 41 1)
                                (cons 42 1)
                    (cons 43 1)
                            )
                        )
                    )
                        (entupd blocks); updates the block
            )
            (prompt "\nNo blocks in drawing!")
       )
      (princ)
      ;(setvar "qaflags" 0)
    )
    16-027Hkjkl.dwg

  2. #2
    Senior Member
    Using
    not applicable
    Join Date
    Jun 2016
    Posts
    297

    Default

    Yes, of course you need to loop over the selection set. Plenty of examples out there. Just search.
    BricsCAD 16

  3. #3
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    743

    Default

    Heres a handy tutorial about how to iterate through a seleciton set.

  4. #4
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    8,638

    Default

    Try this

    Code:
    ;below selects all blocks 
     (setq ALLBLOCKS (ssget "X" (LIST (cons 0 "INSERT"))))
      ;(command "select" allblocks))
    (if  
            (progn
            (repeat (setq x (sslength allblocks))) 
            (setq blocks (ssname ALLBLOCKS (setq x (- x 1))))
                    (entmod ; modifies the properties of the entity
                        (append ; combines the list
                            (entget blocks); indicates what entity to edit
                            (list ; create a list of properties to change
                                (cons 41 1)
                                (cons 42 1)
                                (cons 43 1)
                            )
                        )
                    )
                    (entupd blocks); updates the block
            ) 
            ) ; repeat ?
            (prompt "\nNo blocks in drawing!")
       ) ; progn
      (princ)
      ;(setvar "qaflags" 0)
    ) ; if
    Its just me but I put ) ; if its so I can keep track of the closing pairs makes it easier to add to code like this.
    A man who never made mistakes never made anything

  5. #5
    Senior Member
    Computer Details
    YZ's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    CORE I7 3770 3.4GHZ
    CPU:
    Intel Duo Core E6550 @ 2.33GHz
    RAM:
    16
    Graphics:
    NVIDIA Quadro K600
    Monitor:
    LG Flatron W2343T
    Discipline
    Surveying
    YZ's Discipline Details
    Occupation
    CAD Operator and Manager; Land Survey, Civil Design
    Discipline
    Surveying
    Details
    Topographic ground surveys for architects and engineers; Land Subdivisions; Civil Engineering Design.
    Using
    AutoCAD 2017
    Join Date
    Oct 2007
    Location
    Sydney, Australia
    Posts
    463

    Default

    Registered forum members do not see this ad.

    Thanks BigAl, was able to put something together from your comment and the tutorial above.

Similar Threads

  1. dynamic blocks not correctly work
    By engmech in forum AutoCAD Beginners' Area
    Replies: 2
    Last Post: 25th Jan 2016, 09:32 pm
  2. Replies: 7
    Last Post: 14th Oct 2015, 11:41 am
  3. Exploding work blocks
    By NEWMAN1006 in forum AutoCAD Beginners' Area
    Replies: 5
    Last Post: 16th Mar 2012, 02:26 pm
  4. Replies: 2
    Last Post: 30th Sep 2011, 07:19 pm
  5. Easier way to work with blocks?
    By neuri in forum AutoCAD Beginners' Area
    Replies: 9
    Last Post: 1st Jul 2011, 03:22 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