Author Topic: in desperate need of a lisp  (Read 4625 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
in desperate need of a lisp
« on: April 16, 2004, 12:42:19 PM »
hey guys don't even know if this is possible but if it is i'm sure you guys have tried it. i need a lisp that would change the insertion point of all blocks in a drawing to 0,0 (IMPORTANT PART) without moving them from their current location? it would be a lifesaver thanks...

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
in desperate need of a lisp
« Reply #1 on: April 16, 2004, 12:45:56 PM »
Have you considered what happens when you have 2 inserts of the same block in a drawing ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ELOQUINTET

  • Guest
in desperate need of a lisp
« Reply #2 on: April 16, 2004, 01:13:59 PM »
yeah i was thinking about that being one of the problems just figured i'd throw my line in the water and see if i get any bites

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
in desperate need of a lisp
« Reply #3 on: April 16, 2004, 01:59:45 PM »
I assume the naming convention for the blocks is important for you ??
There are a couple of options available, but you would need to spell out the crireria and logic exactly before writing a line of code.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
in desperate need of a lisp
« Reply #4 on: April 16, 2004, 02:12:08 PM »
precisely... you could change all blocks to anonymous blocks... but this will really get nasty when you have nested blocks
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
in desperate need of a lisp
« Reply #5 on: April 16, 2004, 02:39:48 PM »
Hi Keith .. my initial thought was to create a newblock/insert with the prefix being the original block name, and some sort of numerical suffix.
It will all depend on what type of reporting is required and what automation is already in place.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
in desperate need of a lisp
« Reply #6 on: April 16, 2004, 03:08:49 PM »
Found this:
Code: [Select]

(defun c:moveblocks (/ instpt ss cntr blklist)
  (vl-load-com)

  (setq instpt
        (vlax-make-variant
          (vlax-safearray-fill
            (vlax-make-safearray
              vlax-vbDouble
              (cons 0 2)
              )
            (list 0.0 0.0 0.0)
            )
          )
        )

  ; create a list of blocks
  (if
    (setq ss (ssget "_X" '((0 . "INSERT"))))
    (progn
      (setq cntr 0)
      (repeat
        (sslength ss)
        (setq blklist
              (append
                (list
                  (vlax-ename->vla-object (ssname ss cntr))
                  )
                blklist
                )
              cntr    (1+ cntr)
              ) ; setq
        )

      ) ; progn
    )

  ; remove xref's from list
  (if blklist
    (progn
      (setq blklist
            (vl-remove-if
              (function
                (lambda (x)
                  (vl-symbolp (vlax-property-available-p x 'Path))
                  )
                )
              blklist
              )
            )

      ; modify each block in list
      (foreach x blklist
               (vlax-put-property x 'InsertionPoint instpt)
               ;(vlax-put-property x 'XScaleFactor 1.0)
               ;(vlax-put-property x 'YScaleFactor 1.0)
               ;(vlax-put-property x 'ZScaleFactor 1.0)
               (if (not (vlax-object-released-p x))
                 (vlax-release-object x))
               )

      ); progn
    ); if

  (setq ss nil)
  (princ)
  ); defun
TheSwamp.org  (serving the CAD community since 2003)

ELOQUINTET

  • Guest
in desperate need of a lisp
« Reply #7 on: April 16, 2004, 03:23:53 PM »
well the situation is that i am doing a really complicated stair i grouped different elements of it together as blocks so i can piece the whole thing together but can easily pull the different parts out as i need to coordinate the whole thing. the names are not super important i'm doing it mostly for grouping purposes. i've been creating details then doing a copy with base point then paste as block then making a full section a block. i'll do a saveas and give the lisp a try mark and let you know how it goes. thanks everybody

ELOQUINTET

  • Guest
in desperate need of a lisp
« Reply #8 on: April 16, 2004, 03:30:28 PM »
whoa that's not what i wanted. it moved all the blocks to 0,0 but the insertion point is the same. pretty scary to see all those blocks move though  :shock:

DMSS

  • Guest
in desperate need of a lisp
« Reply #9 on: June 17, 2004, 01:13:38 PM »
Are the blocks "block" or "wblocks"?
Are they nested into groups?  (groups are not the desciding factor on the code to be written)

If I'm getting the jest of what you want to do...

Run a rountine that will find all your "blocks", then, write them out to files as "wblocks" to be used later (is this close??).

If not, explain in detail what you are working with, and what you want to do.

subbup

  • Guest
in desperate need of a lisp
« Reply #10 on: June 21, 2004, 01:54:54 AM »
what he want exactly in my words,
select all the blocks in the drawing,
the present position of the block should be there only. but when you see the insertion point it should be at 0,0.
for this what we can do is go to eachblock,
take the data of block(means name, rotation,layer etc..)
explode that and make that wblock again but the insertion point you have to give is 0,0.
and insert again.
if you guys got confused about this try manually do all these things first. ok..