Export blocks to new drawing

Hey,
I’ve found this thread but I need an algorithm to work in a different way.
I have an algorithm to create rails through railway corridor and split them into parts(for example 25,50,100m). I need every rail to be exported as a new file with name as block name and just to specify targeting folder. I don’t know how to use python script so I will be very grateful if someone helps me with that.
Thanks!

Ok I’m a little bit rusty here but this should do it. I modified the python code so that provided with a list of file paths and a list of object handles, it will run the wblock for each pair (filepath, object handle).

You will need to change the Get Object Group to get the objects you want. Read through the notes and it should be clear :slight_smile:


Wblock_Forum_Test.dyn (30.5 KB)

4 Likes

I had to compress the gif so the quality is low, but it should illustrate how it works
ezgif.com-optimize (1)

1 Like

I was away from my PC these days and I wasn’t able to check it. Thank you!

Thanks for this. Very helpful. I have modified the graph to select all blocks in a drawing and save them to their own files.

2 questions:

  1. How does the code set the units of the resulting file? I need mine to be unitless, and they are currently in feet.

  2. where does it set the insert location of the block in the resulting file. it seems to insert it at the existing location. I would like to make it come in at 0,0. (for now I have just moved all my blocks to 0,0 in the file I run the graph on)