ajayre
Alibre Super User
Here is an overview of some of the new assembly functionality in WizoScript. Note that you need version 3.51 or later to follow along with this.
We can create a new empty assembly:
Now let's add an existing part to it:
Some explanation is needed here. There are a set of six values after the part filename. These are specifying how to place the part into the assembly. They are in order:
The final value is 'True' This tells WizoScript we want to move the part before rotating if. If we wanted to rotate and then move then we would put 'False' here instead.
When a part is added to an assembly we call it an 'occurrence'. This means that we can have multiple occurrences of the same part. If you look at the variable name I used it is 'PartAOcc', short for 'Part A Occurrence'. AD shows this as 'PartA<1>'. We can get AD's name with this:
which will show 'PartA<1>'. Here is how to duplicate the part we have added:
We have added another occurrence of the same part, but we have moved and then rotated it.
Anchoring a part occurrence is easy:
If we have opened an existing assembly we can get part occurrence by name:
Once we have access to a part occurrence we can move it and rotate it:
Note that moving a part does not honor constraints. If you want other parts to also move then you will need to work out the new position and call the MovePart function.
We can add an existing assembly as a sub-assembly:
again with move and rotate parameters.
In addition there are functions to add empty parts and sub-assemblies. See the reference manual for a complete list.
The next tutorial will cover constraints.
Andy
We can create a new empty assembly:
Code:
Test = Assembly("Test");
Now let's add an existing part to it:
Code:
PartAOcc = Test.AddPart(r'C:\Users\Andy\Desktop\PartA.AD_PRT', 0, 0, 0, 0, 0, 0, True)
Some explanation is needed here. There are a set of six values after the part filename. These are specifying how to place the part into the assembly. They are in order:
- X location
- Y location
- Z location
- X rotation
- Y rotation
- Z rotation
The final value is 'True' This tells WizoScript we want to move the part before rotating if. If we wanted to rotate and then move then we would put 'False' here instead.
When a part is added to an assembly we call it an 'occurrence'. This means that we can have multiple occurrences of the same part. If you look at the variable name I used it is 'PartAOcc', short for 'Part A Occurrence'. AD shows this as 'PartA<1>'. We can get AD's name with this:
Code:
print PartAOcc.Name
which will show 'PartA<1>'. Here is how to duplicate the part we have added:
Code:
AnotherPartAOcc = Test.DuplicatePart(PartAOcc, 5, 10, 15, 30, 40, 50, True)
We have added another occurrence of the same part, but we have moved and then rotated it.
Anchoring a part occurrence is easy:
Code:
Test.AnchorPart(PartAOcc);
If we have opened an existing assembly we can get part occurrence by name:
Code:
PartBOcc = Test.GetPart('PartB<1>')
Once we have access to a part occurrence we can move it and rotate it:
Code:
Test.MovePart(PartBOcc, 5, 6.5, 11.2)
Test.RotatePart(PartBOcc, 45.1, 90.2, 180.3)
Note that moving a part does not honor constraints. If you want other parts to also move then you will need to work out the new position and call the MovePart function.
We can add an existing assembly as a sub-assembly:
Code:
SubAssemOcc = Test.AddSubAssembly(r'C:\Users\Andy\Desktop\MySubAssem.AD_ASM', 0, 0, 0, 0, 0, 0, True)
again with move and rotate parameters.
In addition there are functions to add empty parts and sub-assemblies. See the reference manual for a complete list.
The next tutorial will cover constraints.
Andy