Hello
In vba I make a program that opens in an assembly parts (of a bottle) and assembles them (complete bottle).
My problem comes to constrain the pieces in them.
As it is the user who chooses these parts, the mix between the open pieces will change.e.g: flat bottom, rounded bottom, rounded square edge, straight square edge etc...
What I started by doing is to constrain the plans of each room.
Macro registration code
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
boolstatus = Part.Extension.SelectByID2("Wreath face@Bague Plane 26-1@Assemblage Round Edge", "PLANE", 0, 0, 0, True, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Plan of face@EP-BR-ST-1@Assemblage Round Edge", "PLANE", 0, 0, 0, True, 1, Nothing, 0)
Dim myMate As Object
Set myMate = Part.AddMate3(0, 0, False, 0, 0, 0, 0.001, 0.001, 0, 0.5235987755983, 0.523598775983, False, longstatus)
Part.ClearSelection2 True
Part.EditRebuild3
boolstatus = Part.Extension.SelectByID2("Right Plan", "PLANE", 0, 0, 0, True, 1, Nothing, 0)
boolstatus = Part.DeSelectByID("Right Plan", "PLANE", 0, 0, 0)
boolstatus = Part.Extension.SelectByID2("Wreath droite@Bague Plane 26-1@Assemblage Round Edge", "PLANE", 0, 0, 0, True, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Plan of droite@EP-BR-ST-1@Assemblage Round Edge", "PLANE", 0, 0, 0, True, 1, Nothing, 0)
Set myMate = Part.AddMate3(0, 0, False, 0, 0, 0, 0.001, 0.001, 0, 0.5235987755983, 0.523598775983, False, longstatus)
Part.ClearSelection2 True
Part.EditRebuild3
boolstatus = Part.Extension.SelectByID2("Plan_inf@Bague crown 26-1@Assemblage Round edge", "PLANE", 0, 0, 0, True, 1, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("Plan_sup@EP-BR-ST-1@Assemblage Round Edge", "PLANE", 0, 0, 0, True, 1, Nothing, 0)
Set myMate = Part.AddMate3(0, 1, False, 0.071, 0, 0, 0.001, 0.001, 0, 0.5235987755983, 0.5235987755983, False, longstatus)
Part.ClearSelection2 True
Part.EditRebuild3
We can see that there is a space between the two pieces of " 0.071"m and I don't know how to define it. (it will change for each set of parts so too restrictive especially since the part library will grow as you go along)
In my macro I intentionally put Y-shaped spaces to separate the parts when I import them (cf: image) so I know the space between the origin of the assembly and the center of gravity of my part. (is it the center of gravity that is taken into account when importing parts?)
Is it possible to recover the height of the room? (VBA variables)
Or any other ideas are welcome too!
Thank you
JB
assemblage_bouteille.png