1 Reply Latest reply on Feb 13, 2015 2:27 PM by Keith Rice

    Help construct macro to automatically create DXF files of parts

    Sam King

      So I've been trying to create a macro to automatically create .DXF files to send to the plasma cutter.  My assemblies usually have between 300-400 parts, so making these files manually is very time consuming. I'm needing a little help figuring out the correct process I should use in my macro.  Here are the details of what I need to do...

       

      This macro will be run on an assembly

       

      1) Find the components in the assembly with a material specification of "HRS W/J" (I input these materials as I draw the parts.)

      2) Select the largest face and create a .DXF file in another folder. (It will be easy to find the folder, it will be in the same place everytime)

      Here's where I'm having problems...

      3) Before the .DXF File is created, I need to undersize the dowel hole sizes (We cut them smaller then run a reamer through them)

      4) I also need to check for any countersunk/counterbored holes in the largest face

           - If there is any, I will need to change the diameter of the counterbores/countersinks to match the hole size

      5) Also, if we are going to machine a weldment, we will make a configuration of each part named "Plasma"

       

      I'm learning VBA as I go, and I have created one massive (and pretty messy) macro that works sometimes. (It is not very reliable though, about half the time it breaks up the .DXF file into 3 different files)

       

      So I'm thinking I need to drop back and punt and get some advice on doing this correctly. I'm just needing help with the process, the actual code I can figure out.

       

      Here is the process as I see it in my head...

       

      1) Select the open assembly

      2) Cycle through all the components of the assembly

      3) If the material is "HRS W/J" go into a .DXF file function

           Function

                a) Check for multiple part configurations

                b) If there are more than 1, activate the "Plasma" configuration

                c) Select largest face

                d) Cycle through features to find any Hole wizard features

                e) Check for dowel holes and undersize the holes

                f) Check for Counterbores/countersinks and change the diameter dimensions

                g) Use ExportToDwg to save the .DXF file

      4) Keep cycling through the parts.

       

      If anybody has any experience making a macro like this, or has any advice I would really appreciate it.  I'm already on my 6th try of doing this so needless to say I'm quite frustrated already haha

       

      I attached the macro I have.  Like I said, I don't know much about this so it is pretty messy.

       

      Also, in this macro I was trying to select all faces touching the "Front Plane" but I'm thinking selecting the largest face would be easier.