BLOCKS TO GROUPS

BLOCKS TO GROUPS

henry
Participant Participant
529 Views
5 Replies
Message 1 of 6

BLOCKS TO GROUPS

henry
Participant
Participant

I use a 3rd party software with AutoCAD that successfully runs all routines even with grouped objects. The problem is that a group that is copied to a new location is a new group, so modifications to the original group have no impact on the copied group. I typically design a unit, make a block out of that design and copy the block to all typical units. This way if I need to make a change, I edit the block and the change is made at all of those typical units. The issue is that blocks are not recognized as individual objects within it, like groups are, so where a block interfaces an object, the 3rd party software indicates an error and routines are not completed. Any suggestions?

0 Likes
530 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

Can you get into one of the Block editors [BEDIT or REFEDIT] and run the 3rd-party software within that?

Kent Cooper, AIA
0 Likes
Message 3 of 6

henry
Participant
Participant

Thanks for the reply.

Yes, I can do that. The problem is that only one block can be edited at a time which means the other unit blocks which are typical, but not typical to this one, create the same errors in the 3rd party software.

0 Likes
Message 4 of 6

ВeekeeCZ
Consultant
Consultant

Try this. It will copy objects within a group. Either part or all the objects.

It will fail if multilevel groups used.

 

(vl-load-com)

(defun c:Cogy ( / :GetGroupName s n rl) ; copy objects within a group. fails with multilevel groups.
  
  (defun :GetGroupName (e / gl g f)
    (and (setq gl (reverse (dictsearch (namedobjdict) "ACAD_GROUP")))
	 (setq gl (mapcar 'cons
			  (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 3 (car x))) gl))
			  (mapcar 'cdr (vl-remove-if '(lambda (x) (/= 350 (car x))) gl))))
	 (foreach g gl (if (member (cons 340 e) (entget (cdr g))) (setq f (car g))))
	 )
    f)
  
  (if (and (setq s (ssget "_:L"))
	   (setq n (cdr (assoc 3 (reverse (dictsearch (namedobjdict) "ACAD_GROUP")))))
	   (setq e (entlast))
	   (not (command-s "_.copy" s ""))
	   (setq o (:GetGroupName (ssname s 0)))								; group name of old entities
	   )
    (progn
      (while (setq e (entnext e)) (setq rl (cons e rl)))							; all enames of copies
      (if (/= n (setq n (cdr (assoc 3 (setq d (reverse (dictsearch (namedobjdict) "ACAD_GROUP")))))))  		; any group created by copy?
	(progn (command "_.groupedit" "_n" n "_r") (foreach r rl (command r)) (command "")))			; remove all enames from new group
      (command "_.groupedit" "_n" o "_a") (foreach r rl (command r)) (command "")))				; add all enames to old group
  (princ)
  )

 

0 Likes
Message 5 of 6

henry
Participant
Participant
Hi,
I must be doing something wrong. I saved what you sent as an lsp file (cogy.lsp) and loaded it into ACAD but the invoke command “cogy” isn’t showing up in the command list. I don’t know much about these so I don’t know if I had to save it to a specific location or what. If you could help me with that I would appreciate it.

Thanks!
0 Likes
Message 6 of 6

ВeekeeCZ
Consultant
Consultant

There is nothing wrong with the code. See how to load it HERE  Make sure that you copy-paste the entire code!

See how the routine behaves HERE 

0 Likes