AnsweredAssumed Answered

I am try to get started on a macro to create a mated assembly

Question asked by Joe Pickens on Jan 21, 2016
Latest reply on Jan 22, 2016 by Joe Pickens

What I want the macro to do



1.       Open Prompt to select Assembly Templet and prompt to save Assembly.  If ASM file is already open skip first step

2.       Create empty text file with same name as the assembly

3.       Prompt for an Excel file location with the Bill of Material

4.       Search for CAD files that match the part #’s listed in the excel file A6:AX

I.        I file found go to step 5

II.      If file not found write part number in text file in format of part#-File Does Not Exist

5.       Add part to Assembly File

6.       Mate part in assembly file accordingly

I.        Components will have Planes, Axes, and Points  in the feature three listed in importance order.

                                                               i.      Ie. the macro for this part would ignore all default named planes (ie Front Plane, Top Plane, Right Plane, Plane1:PlaneX) and look at unique named planes in order so the first one would be the CENTER PL and see if this plane exists in the open top level assembly and if it does not exist in the top level assembly then it would look the planes in the first component in the ASM and so on and if this plane is not found in and components the macro would move on to the next one which would be the FRT AXLE PL. If the plane is found it is the mated and the macro will move on to the next plane

1.       When inserting a component a plane, axes, point mate will only be done once but it can be mated to other inserting components.

a.       Ie. When part 6 with planeA is being inserted into the ASM  and part 3 and part 4 have planeA as soon as the macro mates part 6 planeA to part 3 planA the macro should move on to trying to mate planeB in part 6 and not continue on trying to mate part 6 planeA to part 4 planeA

II.      Like Geometry will only be mated ie Planes to Planes, Axes to Axes, and Points to Points

                                                               i.      Plane to Plane mates are Coincident

                                                             ii.      Axis to Axis mates are Concentric

                                                            iii.      Point to Point mates are Coincident with axes aligned

III.    Minimal mates are to be used when component is inserted

                                                               i.      Max 3 Planer mates

                                                             ii.      Max 1 Planer mate 1 Axis mate

                                                            iii.      Max 1 Point mate

IV.    If No mates are able to be made the component will be inserted in the position where its origin and the assembly origin are the same





Pseudo Code


1.       If SolidWorks assembly is not active then prompt to choose assembly templet

2.       Create text Document

3.       Set Assembly to Visable

4.       Prompt for excel document to use for Bill of Material

5.       Use Part #’s found in A6:AX to find Component files in found in Solidworks EPDM CAD folder and SubFolders

6.       If component not found write to text file in format AX not in SolidWorks

7.       If component found then Insert the component into Open Assembly where the Component Origen and Assembly origin are in same spot

8.       Search part Feature tree for Points first then Planes then Axes that don’t have a default name scheme

9.       Take first found feature in part and see if it matches its equivalent in the open assembly then in the preceding parts in the order they are in the assembly tree

10.   If match found then mate

11.   If mate causes mate error then remove mate

12.   if Comonent is fully confined then go back to step four and compile for AX+1

13.   If component is not fully defined look at Components Mates folder and if there is a Coincident and a Concentric mate then go back to step four and compile for AX+1


14.   If component is not fully defined look at Components Mates folder and if there is NOT a Coincident and a Concentric mate then Move next Plane or Axis