1 Reply Latest reply on Apr 10, 2015 10:00 AM by Deepak Gupta

    Create Assembly from chosen parts

    Michael Brigmann

      Hi guys,

       

      I trying to write a Macro with assembly parts automaticly. Those are chosen in a userform and loaded into an Assembly.

      So far it works and it puts all the parts nicely together.

       

      The parts are for now a very simple bolt with a head and a Plate with a hole in it. The bolt goes in the hole and is assembled with the face of the head on the plate... done.

      Now comes the tricky part...

       

      The idea is to have different configurations of the parts e.g.

       

      Plate

           Round

           Square

           Large

           Small

           [...]

       

      Bolt

           Long

           Short

           [...]

       

       

      They all have in common that the assemblies are the same. Hole with bolt and face with face.

      My approach would be to rename the geometries which are involved...  FaceBoltHead; PlateHole; FaceBoltStud; PlateFace.

      This way it would be possible to use a string to choose the parts and to assemble them throught the defined geometries.

       

      What the code is for this action.

       

      Can someone help please.

       

       

      Currently I am using the code from the Macro recorder which assembles the geometrie according to coordinates in the assembly (???)

       

       

      boolstatus = Part.Extension.SelectByID2("", "FACE", 9.18451425339413E-02, 6.48748348618824E-02, -2.26877194412509E-02, True, 1, Nothing, 0)

      boolstatus = Part.Extension.SelectByID2("", "EDGE", 8.01952218606061E-02, 9.54887750269222E-02, 0.165563724364461, True, 1, Nothing, 0)

      Set myMate = Part.AddMate4(0, 0, False, 0.001, 0, 0, 0.001, 0.001, 0.5235987755983, 0.5235987755983, 0.5235987755983, False, False, longstatus)

      Part.ClearSelection2 True

      Part.EditRebuild3

       

      Thanks for the Help

       

      Cheers