14 Replies Latest reply on Mar 23, 2015 4:06 AM by Timo Laaksonen

    Splitting a body and exporting slices as DXF

    Nick Vande Waerdt



      I’ve got an issue I'd like to share with the forum.  We have struggled with this one for awhile.  It’s not an issue with SW functionality, more like we could use some help getting where we need to go.


      I have attached a model of a forming die to go in a hydraulic press.  It has 2 configurations, sliced and solid.  The top curved part is what does the forming.  The bottom flat part with the cut going across at an angle is so we can put the die together in the correct order after we get the parts off the laser.


      BACKGROUND:  Normally this type of part might be milled as a solid part by a die-maker, but since we have lasers, we cut individual segments (“slices”) out of flat steel (usually ¼”) and bolt them all together to make our die (see attached picture).  There are 99 segments in this particular die.  In this way we end up with approximately the same shape as if we had milled the shape solid.  This picture is not the exact same die as is in the SW file, but it’ll give you an idea of what we’re doing.


      The goal in SolidWorks is to go from our solid model of the die to 99 individual DXF files that can be cut on our lasers.




      1.       Use the Split command on the attached model to create and save out individual bodies of all the slices.  This is already done in the “Split” configuration of the attached model.

      2.       Use Task Scheduler to create drawings of all the individual slices.  We created a special drawing template (attached) that has a pre-defined view in 1:1 scale, and nothing else.  Task Scheduler creates a drawing using this template, then saves it in a different folder.  It does this for all 99 slices.

      3.       Next, Task Scheduler exports all the drawings as DXF’s.  It does this for all 99 slices.

      4.       HERE’S THE PROBLEM:  Because of the way the die curves, the DXF file that Task Scheduler is not a clean profile, it “sees” both sides of the die.  To fix this, we have to open up all 99 individual DXF’s in AutoCAD or DWG Editor (shudder) and physically delete the extra lines.  As you can imagine, this takes a lot of time.  I attached a DXF file for an example, you can see in the upper left corner, there are 2 lines shown if you look closely.  Our laser software cannot handle this, it needs a clean profile to cut.



      ·         Creating a Cut-Extrude on each individual slice of the die that shaves off the extra material, so the DXF will be clean.  We are not very gifted in API, but we have attempted to create a macro that would allow us to open the solid model of each slice, click on the appropriate face, and run a macro to open a sketch, do a Convert Entities on the face you selected, select Cut-Extrude, (Through All, Flip Side to Cut), hit OK, then Save, then Close.  We tried recording a macro for this, but it only works intermittently.  If we had a Cut-Extrude like this on each body before we created drawings and exported DXFs, our DXF would come out clean.

      ·         Creating 99 Cut-Extrudes before the die is Split, so the sliced bodies would be clean.  This consist of an Intersection Curve at each of Cutting Planes on the “Bottom of Die.sldprt.”  That Intersection curve is a 2D sketch if the plane is pre-selected.  It could then be cut-extruded a ¼” in the proper direction to shave off the outside of the slice.  The body could then be split, and processed with Task Scheduler as before.  This solution is also quite time-consuming.

      ·         Making the DXF easier to clean in AutoCAD or DWG Editor.  If we could “Select Loop” somehow on the 2D DXF file, it would be much easier to clean the DXF files if they had those extra lines.


      Maybe you guys could lend a hand on this one?  Sorry for the long-winded explanation.  I also posed this question to Stump the Chumps for SW World this year.


      We are already light-years ahead of the way they used to do it before I was around.  They used to create a drawing with a front view of the die, then created 99 section views on the drawing, one every ¼” apart.  They then exported this entire drawing as a DXF file, and spend 3 days sorting out all the individual section views and saving them individually.  Now we can run Task Scheduler overnight and have a pile of DXF's to clean when we arrive in the morning.

        • Re: Splitting a body and exporting slices as DXF
          Robert Hoyt

          Maybe you could  use the "project curve"  feature to generate 2d curves on the part surfaces? I can't open your model until I update my SW (future version error) to really get into your modeling methodology, and I'm not sure if there's a direct enough path from "curves" to "DXF" to suit your needs, but certainly the curves won't have the same "double edge" problem you're running into with sliced solid bodies, and might be a direction you haven't yet explored.

          • Re: Splitting a body and exporting slices as DXF
            Anna Wood

            What about a group of planes and use those planes to create intersection curves?





              • Re: Splitting a body and exporting slices as DXF
                Nick Vande Waerdt
                We considered this, but unless a macro could be written, it is quite time-consuming to do 99 times.  To get a 2D sketch from an Intersection Curve feature, the plane needs to be pre-selected.  After the command is activated, one needs to "Select Tangency" on the die to create the sketch.  Then this sketch needs to be Cut-Extruded one material thickness (1/4" in this case) with "Flip Side to Cut" selected.  If the macro would create the Cut-Extrude from a pre-selected plane and pre-selected faces, that would make it easier...
                  • Re: Splitting a body and exporting slices as DXF
                    Anna Wood

                    I was assuming you would want a macro to do this including saving out to DXF files all named the way you wish.  I wouldn't consider doing it any other way.


                    I suspect you may be able to get someone over in the API sub-forum to help you out.  I would write the macro to do this with intersection curves.  Then the macro would not have to decide which set of lines to delete from the solid slices.


                    I think you could get the process down to minutes with a macro.  If you had to pay someone to write a macro it would be worth it for the times saving you could get.





                • Re: Splitting a body and exporting slices as DXF
                  Craig Pretty

                  I have had a bit of a go at this for an 'art' project but in two dimensions.  Surfacing tools are quite usefull for this.


                  See attached model for an idea to expand into a possible solution.  I have created a single surface where the location is controlled by a design table.


                  To create your DXF files all you need is a macro or task scheduler that opens a drawing for each configuration.  You may be able to have a single drawing and step through the configurations in that drawing.


                  Hope this helps, or puts you onto the path of an easy solution



                    • Re: Splitting a body and exporting slices as DXF
                      Nick Vande Waerdt

                      Craig, this will work for us!  Thanks!


                      So, to summarize, here is our new approach:


                      We take the solid model of the die and create a surface that is the profile of the die.  This is done using surface tools, see attached.


                      We then use a Design Table to make configurations for the location of this surface that was just created.  We did this in 1/4" increments, for a total of 98 slices/configurations.  We used a Delete Body command to get rid of the top-level solid for each configuration.


                      We found a macro that exports the flatpattern of every configuration in a part.  To utilize this, we had to convert each individual slice into sheetmetal.  To do this, we Thickened the slice, then Insert Bents to convert to sheet metal.  Now each configuration contains a single slice, with all normal faces, so there will be no shadow on the DXF.


                      Next we run the macro.  The macro exports the flatpattern of each configuration to a DXF.  It took about 15 minutes to spit out 98 DXF files.  This is an enormous time savings over our old method!


                      I'll attach the new solid model showing the Design Table and the configurations.  I'll also attach the macro.


                      Thanks everyone for your great ideas!  I think we've found a workable solution!




                        • Re: Splitting a body and exporting slices as DXF
                          Anna Wood

                          Excellent, glad to hear you found a solution.


                          Also, thanks for taking the time for posting your process.  It will be helpful for those in the future who may have the same need as your engineering group.


                          Here is an alternate solution that will save you a few features.  You can eliminate the need to do all the surface offsets.  Before you trim your one surface to the part envelope, delete an end face.  This will leave you with a knit surface body.  Then trim your surface to the knit surface body. I suspect this will save you a couple more minutes of work.


                          You also do not need to create the 3D sketch to constrain the Cut Extrude-3.  Delete the 3D sketch, then delete the two coincident constraints that are bad.  Then take the vertical line that is blue and constrain it collinear to the vertical edge it wants to be collinear to.


                          I have attached an example for you.





                      • Re: Splitting a body and exporting slices as DXF
                        Daymon Hoffman

                        Hello Nick,


                        These are just a couple of ideas to put your way and if one tickles your fancy you could look into it.  I've done similar things to how you do these dies only mine usually aren't as large.   But basically the exact same idea.


                               Why not try using the Drawing side to acheive this?    Put a "TOP" view in a drawing (doesnt matter what scale as you can 1:1 on DXF/DWG output, but you may as well make it 1:1 to save any errors creaping in) and use the "Section View" tool to create sections.  You can turn on "Display Only Cut Surfaces" which totally eliminates your thickness double profile issue.  Also in your part you can specify "none" for your hatch pattern so you just get the exact profiles (perfect for Laser, and trust me i know what is or isnt perfect for a Laser!)  THe challengers i foresee doing it this way are.. A)you havea ll your profiles in one drawing instead of seperate DXF files. This seems minor problem compared to fixing double thickness shilloettes though!   B)You have to create the many section views.  Now this could probably be automated quite easily with some kind of progammer/nerdy skillz.  They could simply use your predefined section planes and "grab" those and coincident mate with the line for the section view and also set the relevant options as stated above.


                        Then if required you could get your secretery to save each profile to seperate DXF's after th emain DXF/DWG export.   Though for a spart API guy thats probably a 5 minute job to automate.


                        Some other thoughts as i've been typing... you could perhaps not even use the Planes and just use a sketch array of the section line in the drawing.  Once you've manually created the 100 sections you could then just do file copy sand change referenced parts and array gaps to suit sheet thickness for each job if required and it'd update all the views you've layed out.  THis is probably quicker then fixing up your DXFs in your current method.


                        Hope this helps!


                          • Re: Splitting a body and exporting slices as DXF
                            Timo Laaksonen

                            Hi All


                            For this problem this seems like the best option.. But do not create multiple cuts.. just one is enough..

                            The trick is so dimensions the sections sketch line (edit sketch of the section) from the side of the model.. this way a simple macro is needed:

                            1) modify the dimension of the section location ( for this you need the thickness parameter).

                            2) rebuild

                            3) And save the section view to new DXF file..


                            this way the manual work in the drawing is minimised..

                          • Re: Splitting a body and exporting slices as DXF
                            Nick Vande Waerdt

                            I have a new approach to this problem to share with the forum.  When I started this thread with this question, I had also sent this question to the "Stump the Chump" panel from SW World. Bill Briggs, Sr Technical Support Engineer for SolidWorks, one of the "Chumps," came up with a solution that is faster and more efficient than the previous solution I had posted.  Here it is.  I'll post Bill's original explanation:


                            I place the die into an assembly and orientate it so that the top plane of the assembly is coincident to the top face of the die with the body of the die extending up in the Y direction.  I then create 99 planes starting at the top plane of the assembly at .25 intervals, similar to the way you had done it in the die model you sent.  Then, I create sketches of instersection curves at each of the planes through the die.  By orienting the die in an assembly, I know that the body of the die will be consistently located despite what methods and orientation it was modeled with.  I then create a temporary drawing with a single view looking at the top plane of the assembly.  I hide the die body and all the sketches and then one by one a show a single sketch at a time on the drawing and save the dxf file.


                            You could in theory, prep several parts, each in their own assemblies.  You could then schedule a task to run a custom macro on those assemblies and just walk away and let it finish.  It takes only a minute to create an assembly and mate the die into position.  I just timed the macro on the most powerful PC we have in our lab and it took 3 minutes to complete.


                            I started off with a different method that created parts or even bodies with the cross sections but it was too slow so unless there was some benefit to you to have an assembly with the individual parts/bodies cut squarely as they would be from the laser, than I don’t recommend that method.


                            The program uses two constants that could be controled either through startup parameters  or a UI.  One is for the number of cross sections and the other is for the spacing.  I don’t know if all your dies are the same length or if you aways use .25 inch plate, if not this program will allow you to very those two values to suit any die length and plate thickness.


                            Like Bill's explanation said, you need to adjust 2 parameters at the beginning of the macro to suit your die:  slice thickness and die length.


                            For our own use, we also adjusted the macro to point to the SW "Template" folder on our network, so we didn't have to have a copy of the DXF Template with every part.  I posted Bill's version of the macro, you just need to have the template in the same folder as your part.


                            I'll attach Bill's macro and DXF drawing template.  Many thanks to Bill for his great work on this!!!


                            By the way, I attended the last Stump the Chump session at SW World, it was highly entertaining, and I even learned some stuff too!  I recommend it to anyone that can make it, this year's session is Tuesday 4:30-6:00.



                              • Re: Splitting a body and exporting slices as DXF
                                Matthew East

                                This is a very useful API.  Is anyone familiar how to make it compatible with 64 bit 2014 SolidWorks?  I've tried all available online tutorials to force compatibility, but I suspect the problem relates to the format of some DLL files.  Thanks!

                                  • Re: Splitting a body and exporting slices as DXF
                                    Deepak Gupta

                                    You may need to update/correct the macro reference as suggested here Fix-Update SOLIDWORKS Macro References (don't worry on the fact that video is for fixing missing library error but check the process to update your macro library).

                                      • Re: Splitting a body and exporting slices as DXF
                                        Matthew East

                                        Thanks Deepak,


                                        This API does create layers and cut SectionPlanes through the model before failing in SolidWorks 2014.  I just need to make the last few Subs work in Bill's API, to generate temporary sketches from the SectionPlanes and export DXF's one slice at a time.


                                        I tried to slice off SectionPlane 1, and Create a Section View that hides everything past SectionPlane 2 (so that only a small slice between 1 and 2 is shown) and export the "Current view" as a DXF (using another API which you created).  It then loops , exporting the view between SectionPlanes 2 and 3, 3 and 4, etc... until SectionPlane N. But it seems the DXF export ignores the Section View when writing the "Current view," and just prints "SectionPlane N" every time.


                                        When exporting a DXF manually, I cant export the SectionPlane cuts without manually selecting faces/loops/curves; which I couldn't figure out how to automate in an API.  I've also double checked that it's not a PtrSafe/PtrLong problem, and a few other ideas.