Separating a dxf file with multiple drawings.

Separating a dxf file with multiple drawings.

clerigoaaron
Contributor Contributor
575 Views
8 Replies
Message 1 of 9

Separating a dxf file with multiple drawings.

clerigoaaron
Contributor
Contributor

Hello. I have a dxf file that has multiple drawings of pipes that needs to be separated into their own dxf file for printing. The drawings of the pipes are arranged vertically and in the order of a list as written in an excel file. File name of the separated file will be extracted from excel and each pipe has a fixed length (depending on project) and is spaced evenly by 700mm apart. I usually use the wblock command and select them manually but the pipe ranges around 20-30 each project and was wondering if there is anyway to do this automatically. Thank you

0 Likes
576 Views
8 Replies
Replies (8)
Message 2 of 9

Moshe-A
Mentor
Mentor

@clerigoaaron hi,

 

i assume there is a way to automate this, please, post a sample dwg.

 

Moshe

 

0 Likes
Message 3 of 9

Sea-Haven
Mentor
Mentor

Like @Moshe-A if the pipes were to have a box around them there are many plot routines that can be simply changed to do a dxfout instead. Some of the plot requests have rows of boxes. So same for your request. A 5 minute answer if you do a little on your side. Look at Rectang and Array to make the boxes on a layer.

SeaHaven_0-1737450549948.png

 

 

0 Likes
Message 4 of 9

clerigoaaron
Contributor
Contributor

I can only post sample pictures as only my work computer has autocad. The dxf looks like this. the length of the drawing is constant but different per project. width is fixed at 200. I can add boxes around them to make plotting points easier but how will that look like in lisp? also if is it possible to extract file name in excel? the pipe number will be its file name. drawing number is in column A and Pipe no. in column B.

clerigoaaron_1-1737591895057.png

 

474388200_552862181089241_4615313274322493776_n.jpg

473677348_535362116219659_8842583544099486382_n.jpg

0 Likes
Message 5 of 9

Sea-Haven
Mentor
Mentor

When I talk rectangs that is what I mean, we can look for plines on a layer around the area of your pipes. So this is the code for the two corners, it is used in the dxfout command using a window. The dxf's could say be made as a 1st go in same directory as the dwg. Ie dxf1, dxf2 and so on. Or some other name that you want. I entered 44 as dxf number.

 

SeaHaven_0-1737610588295.png

(defun c:dxfwow ( / x dwgname pre fout co-ord ss)
(setq num (getint "\nStarting number for dxf's "))
(setq dwgname (cadr (fnsplitl (getvar 'dwgname))))
(setq pre (getvar 'dwgprefix))
(setq fout (strcat pre dwgname))
(while (setq ent (car (entsel "pick rectang object Enter to stop ")))

  (setq co-ord (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ent))))
  (setq co-ord (cons (last co-ord) co-ord))

  (setq ss (ssget "WP" co-ord))

  (command "dxfout" (strcat fout (rtos num 2 0)) "E" ss "" "V" "2007" 8)
  (setq num  (1+ num))
)
(princ)
)
(C:dxfwow)

 

 

Not sure what your talking about re Excel.

0 Likes
Message 6 of 9

clerigoaaron
Contributor
Contributor

Thanks will try that. About the excel sheet, sorry i guess the excel and the picture didnt match, may have caused confusion.

I am not knowledgeable on lisp but wondering if it is possible to get the file names for these separated dxf from the excel because these pipes are position as you see on the excel. Pipe 12L will be the first pipe from top to bottom and so on. So i am imagining that if the code loops from top to bottom it can maybe extract the text in excel and use them as the file name and loop down with it. Just wondering 

0 Likes
Message 7 of 9

Sea-Haven
Mentor
Mentor

It may be easier to write the excel when doing the dxfout, if the dwg number and pipe reference are say within a pline then taht can be found and used as the dxf name and added to a Excel file.

 

Can you post a real dwg to look at ?

0 Likes
Message 8 of 9

clerigoaaron
Contributor
Contributor

@Sea-Haven Sorry been busy the past month. Thank you for the code it works nicely. I would like to ask if there is a way to not use the original file name and just make the separated dxfs have a name like 44.dxf and so on. Also If it can accept file names such as 44R. I see that it automatically loops so that the next selection becomes 45 but the drawings are not in chronological order it skips sometimes from 44 to 50. I think having the user type the name for each selected rectangle would suffice. Thank you.

 

Regarding the dxf file i have asked the company and was rejected. I cannot obtain the file to post

0 Likes
Message 9 of 9

Sea-Haven
Mentor
Mentor

You don't need to post a real dwg but something that is very close, it could have random circles in each box but it would allow us to look at the way the surrounding box is made, so we can make sure they are in sequence and so on. If the "part dwg" has a text label please include that as that may the link to the Excel.

 

It is very hard sometimes to provide a solution without a dwg to test on.

SeaHaven_0-1740112870746.png

 

 

 

0 Likes