Author Topic: Move Block Grips as a Group  (Read 3716 times)

0 Members and 1 Guest are viewing this topic.

polhub

  • Guest
Move Block Grips as a Group
« on: November 01, 2017, 01:47:02 PM »
We have a set of dynamic blocks, each block has two points (grips); one input, one output. We use many of these blocks in our drawing packages and it becomes cumbersome to click on each block, then shift click on the grip we want to move.

I am looking for a method that will be more similar to the move command where I draw a crossing window (or fence) and can move a group of either input grips or output grips. I have done some research and, from what I can find, this may not be possible, but of course unless I hit the exact terms in Google things like this are always hard to find. Does anyone have experience with a situation like this, is it possible?

Thanks

polhub

  • Guest
Re: Move Block Grips as a Group
« Reply #1 on: November 14, 2017, 11:47:28 AM »
81 views and no responses, don't know if that is good or bad.

I found this but it applies to the attributes not specifically to a grip.

https://www.theswamp.org/index.php?topic=19881.0

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Move Block Grips as a Group
« Reply #2 on: November 14, 2017, 11:50:05 AM »
Can you post an example of this block you're trying to move? I'm not quite understanding your intentions.
« Last Edit: November 14, 2017, 11:57:13 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

polhub

  • Guest
Re: Move Block Grips as a Group
« Reply #3 on: November 14, 2017, 01:34:33 PM »
If you look at the attached I have included four of the same block in question. If i wanted to move only the four diamond shapes on the right (and their associated attributes) and leave the ones on the left where they are I need to window them then shift click each one individually to move them. I am looking for a simpler process, we can have hundreds of these in a drawing usually in groups of 4 to 10 that we need to move on a regular basis and all the clicking is tedious.

This is one block to allow us to fill in other text via fields so separating the ends to make two blocks isn't really an option.

Crookedmonk

  • Newt
  • Posts: 30
Re: Move Block Grips as a Group
« Reply #4 on: November 14, 2017, 03:39:47 PM »
Are you looking to move the position 2 coordinates to a know location, or to locate to a "random" location?

polhub

  • Guest
Re: Move Block Grips as a Group
« Reply #5 on: November 15, 2017, 07:21:21 AM »
It is a random location. Ultimately we would like to be able to window a group of either position 1 or position 2 and move them like the standard move command.

Crookedmonk

  • Newt
  • Posts: 30
Re: Move Block Grips as a Group
« Reply #6 on: November 15, 2017, 09:06:59 AM »

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Move Block Grips as a Group
« Reply #7 on: November 15, 2017, 10:25:23 AM »
Give this a try:
Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:foo (/ a b bp c l mp p p1 p2 s x x1 x2 y y1 y2 _x _y)
  3.   ;; RJP - 11.15.2017
  4.   (if (and (setq p1 (getpoint "\nSpecify first corner: "))
  5.            (setq p2 (getcorner p1 "\nSpecify opposite corner:"))
  6.            (setq l (list p1 p2))
  7.            (setq l (list (apply 'mapcar (cons 'min l)) (apply 'mapcar (cons 'max l))))
  8.            (setq s (ssget "_C" p1 p2 '((0 . "insert") (2 . "`*U*,SL-WIRE-FLAG"))))
  9.            (setq p
  10.                   (mapcar
  11.                     '(lambda (x)
  12.                        (if (setq p1 (vl-remove-if-not
  13.                                       '(lambda (c) (wcmatch (strcase (vla-get-propertyname c)) "POSITION*"))
  14.                                       (vlax-invoke x 'getdynamicblockproperties)
  15.                                     )
  16.                            )
  17.                          (list (vl-sort p1
  18.                                         '(lambda (a b) (< (vla-get-propertyname a) (vla-get-propertyname b)))
  19.                                )
  20.                                (vlax-get x 'insertionpoint)
  21.                          )
  22.                        )
  23.                      )
  24.                     (vl-remove-if-not
  25.                       '(lambda (d) (vlax-write-enabled-p d))
  26.                       (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))))
  27.                     )
  28.                   )
  29.            )
  30.            (setq bp (getpoint "\nSpecify base point: "))
  31.            (setq mp (getpoint bp "\nSpecify second point: "))
  32.       )
  33.     (foreach x (vl-remove 'nil p)
  34.       (mapcar 'set '(x1 y1 x2 y2) (mapcar '(lambda (y) (vlax-get y 'value)) (setq c (car x))))
  35.       (setq _x (car (cadr x)))
  36.       (setq _y (cadr (cadr x)))
  37.       (if (setq a (cond ((and (<= (car (mapcar 'car l)) (+ _x x1) (cadr (mapcar 'car l)))
  38.                               (<= (car (mapcar 'cadr l)) (+ _y y1) (cadr (mapcar 'cadr l)))
  39.                          )
  40.                          (list (car c) (cadr c) (list x1 y1))
  41.                         )
  42.                         ((and (<= (car (mapcar 'car l)) (+ _x x2) (cadr (mapcar 'car l)))
  43.                               (<= (car (mapcar 'cadr l)) (+ _y y2) (cadr (mapcar 'cadr l)))
  44.                          )
  45.                          (list (caddr c) (cadddr c) (list x2 y2))
  46.                         )
  47.                   )
  48.           )
  49.         (progn (setq b (polar (last a) (angle bp mp) (distance bp mp)))
  50.                (vlax-put (car a) 'value (car b))
  51.                (vlax-put (cadr a) 'value (cadr b))
  52.         )
  53.       )
  54.     )
  55.   )
  56.   (princ))
« Last Edit: November 16, 2017, 08:56:43 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

polhub

  • Guest
Re: Move Block Grips as a Group
« Reply #8 on: November 15, 2017, 11:34:03 AM »
ronjonp,

Nice!

I am a bit confused though, it works in the drawing I sent you but I can't make it work in any other drawing. Can you think of why that would be? I copied the block (from the drawing I sent you) to a new drawing and it no longer works, very strange.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Move Block Grips as a Group
« Reply #9 on: November 15, 2017, 11:54:52 AM »
I just realized that the x y point values are relative to the block insertion point  :oops: . Gimme a bit and I'll try to fix :)

*Code fixed above .. give it a try!
« Last Edit: November 15, 2017, 12:45:43 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

polhub

  • Guest
Re: Move Block Grips as a Group
« Reply #10 on: November 15, 2017, 01:51:18 PM »
Works like a charm!! Never thought that could be done!

Now, do I just change the block name in line 7 if I have other blocks that work the same or can I add a comma and list the others?

Can you clarify the use of the `*u*, I am unfamiliar with that?

Thanks, this should save some time. BIG thumbs up to you (no thumbs up imogee available)

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Move Block Grips as a Group
« Reply #11 on: November 15, 2017, 02:17:00 PM »
Works like a charm!! Never thought that could be done!

Now, do I just change the block name in line 7 if I have other blocks that work the same or can I add a comma and list the others?

Can you clarify the use of the `*u*, I am unfamiliar with that?

Thanks, this should save some time. BIG thumbs up to you (no thumbs up imogee available)
Glad to help out :)
As far as the block filter goes, you should be able to add your names to it "`*U*,SL-WIRE-FLAG,block1,block2..." and the code should work if they have the same point parameters. The`*U* filter catches any dynamic blocks that have been modified since their DXF 2 code changes.
« Last Edit: November 15, 2017, 02:25:55 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

polhub

  • Guest
Re: Move Block Grips as a Group
« Reply #12 on: November 15, 2017, 04:04:57 PM »
I thought as much and added four other blocks no luck only the attributes move not the line work and only one side moves. These have attributes like the block above but also employ visibility states and lookup tables. I am not sure if that has anything to do with it or not.

Thanks again for the help you have provided thus far.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Move Block Grips as a Group
« Reply #13 on: November 15, 2017, 04:11:04 PM »
I'd have to filter out only point parameters ... that's why it's not working. Are they all named "Position*"?

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

polhub

  • Guest
Re: Move Block Grips as a Group
« Reply #14 on: November 16, 2017, 07:44:36 AM »
Yes, on the left side there is Position 1 (the one we want) and Position 3, on the right side it is Position 2 (the one we want) and Position 4. Positions 2 and 4 move a bit of text relative to Positions 1 and 2 respectively, I hope that makes sense.