Convert (Un)named Groups to Blocks

Convert (Un)named Groups to Blocks

jtm2020hyo
Collaborator Collaborator
2,235 Views
9 Replies
Message 1 of 10

Convert (Un)named Groups to Blocks

jtm2020hyo
Collaborator
Collaborator

I need convert 1000 groups to 1000 blocks.

 

I need each angle to be detected for LISP code, I have groups with same elements but are rotated.

 

no matter if groups or block are unnamed or named.

 

In Google, I found this one lisp but just work with 1 group at each time :

 

; rename version
; original code by ASMI rename by Alan H
(defun c:pb (/ lPt)
(and(setq lPt(getvar "LASTPOINT"))
(vl-cmdf "_.copybase" lPt (ssget) "")
(vl-cmdf "_.pasteblock" lPt)
(setq objname (assoc 2 (cdr(entget (entlast))))) 
(vl-cmdf "_.erase" "_p" "")
(command "-rename" "block" (cdr objname) (getstring "Enter new name"))
)
(princ)
); end of c:pb

 

0 Likes
2,236 Views
9 Replies
Replies (9)
Message 2 of 10

cadffm
Consultant
Consultant
One objects can be member of 200 groups,
One object can only be a item of ONE block.

So a really well written program need to use how to work with this possibility.

For all groups in one step it needs a totally other way (or you have to use option groups of ssget).

Sebastian

0 Likes
Message 3 of 10

cadffm
Consultant
Consultant
If you upload the (one?) file, or send by mail (adress in my profile), i will do it for you this one time.

Sebastian

0 Likes
Message 4 of 10

jtm2020hyo
Collaborator
Collaborator

@cadffm wrote:
One objects can be member of 200 groups,
One object can only be a item of ONE block.

So a really well written program need to use how to work with this possibility.

For all groups in one step it needs a totally other way (or you have to use option groups of ssget).


each group does not have shared objects with others groups.

i just need a lisp to convert each group to block. no matter how.



0 Likes
Message 5 of 10

cadffm
Consultant
Consultant

"each group does not have shared objects with others groups."

It is good that you know that for your data, but for a program it should be indepent what the user mean and it should can handle all situations as well.  In this case of an object is member of multiple groups,

for example you define a rule like that:  If an object is a member of multiple groups, then each block should contain a copy of this object.

 

"i just need a lisp to convert each group to block. No matter how."

No matter how to get or work a program? Then ask your friendly programming service provider, who looks forward to orders.

Or wait for better answers, or search more for a program to do that.

 

If no matter how is get groups to blocks.. You had the chance to send me the file and you didn't use it.

 

 

Sebastian

0 Likes
Message 6 of 10

DannyNL
Advisor
Advisor

@jtm2020hyo wrote:

each group does not have shared objects with others groups.

i just need a lisp to convert each group to block. no matter how.


Just curious; why would you want to do that?

 

That would mean each group/block is unique in your drawing, while in short blocks are used to group objects and this group of objects needs to be replicated in your current and/or other drawings.

What is the use of 1000 blocks if they are unique and only used one time. There is no directly added value by converting them to blocks.

Message 7 of 10

jtm2020hyo
Collaborator
Collaborator

@DannyNL wrote:

@jtm2020hyo wrote:

each group does not have shared objects with others groups.

i just need a lisp to convert each group to block. no matter how.


Just curious; why would you want to do that?

 

That would mean each group/block is unique in your drawing, while in short blocks are used to group objects and this group of objects needs to be replicated in your current and/or other drawings.

What is the use of 1000 blocks if they are unique and only used one time. There is no directly added value by converting them to blocks.


 

Those Unnamed Groups are generated for the program DIALUX, DIALUX drops a lot of Lamps with 3D polylines in Groups and I need replace all of them for a real 2D block in AUTOCAD 2018. 

 

I'm working with 13 LAMPS but DIALUX drops all of them in Groups with a different rotation.

 

I need a LISP routine to convert all of them to block because I already have a LISP to REPLACE ANY BLOCKS for ONE BLOCK, I will replace it one for one. if possible creates LISP than can detect the same group with a distinct angle, might be great. for now, I'm working manually. I bet a lot of people have the same problem.

0 Likes
Message 8 of 10

jtm2020hyo
Collaborator
Collaborator

@cadffm wrote:

"each group does not have shared objects with others groups."

It is good that you know that for your data, but for a program it should be indepent what the user mean and it should can handle all situations as well.  In this case of an object is member of multiple groups,

for example you define a rule like that:  If an object is a member of multiple groups, then each block should contain a copy of this object.

 

"i just need a lisp to convert each group to block. No matter how."

No matter how to get or work a program? Then ask your friendly programming service provider, who looks forward to orders.

Or wait for better answers, or search more for a program to do that.

 

If no matter how is get groups to blocks.. You had the chance to send me the file and you didn't use it.

 

 


if possible detect the group with a different name but with same objects, might be great. 

 

I'm sharing my files, I will receive more and more files from DIALUX and I need replace groups of similar objects for one unique block of my LEGEND. if possible create LISP routine that can duplicate elements from same objects its ok, but if not I will BEDIT each block. I just need to create a block from groups with the same center point that Groups already have.

0 Likes
Message 9 of 10

jtm2020hyo
Collaborator
Collaborator

all groups are like this :

 

image.png

0 Likes
Message 10 of 10

jtm2020hyo
Collaborator
Collaborator

First attached are all my LISP routines that use to work.

 

Second attached are the files exported from DIALUX. I need convert that files to blocks.

 

Third attached is the example of how should be done the work. 

 

I appreciate a lot your help, but I need update constantly those files. so I need one or multiple LISP routines.

0 Likes