What's new

Tutorial - Constraints in WizoScript

ajayre

Alibre Super User
A short introduction to adding constraints. This tutorial requires WizoScript 3.50 or later.

First we create a new empty assembly:

Code:
Asm = Assembly("Test")

Now we load in a part and place it at the origin:

Code:
NewPart1 = Asm.AddPart(r'C:\Users\Andy\Desktop\PartA.AD_PRT', 0, 0, 0)

next we duplicate it:

Code:
NewPart2 = Asm.DuplicatePart(NewPart1, 0, 0, 0)

and at this point the two parts are overlaid on top of each other, i.e. occupying the same space.

Now we mate the parts using reference planes for each part:

Code:
Asm.AddMateConstraint(20, NewPart1, NewPart1.GetPlane("XY-Plane"), NewPart2, NewPart2.GetPlane("XY-Plane"))

Some explanation is needed for this function call. The first value '20' is the mate offset in the script units (which default to millimeters). Next we specify the first part to constrain followed by what to constrain. Then we specify the second part and what to constrain for it.

There is an alterative version of this function that allows the mate to be reversed and a name specified for the constraint.

Next we add a align constraint:

Code:
Asm.AddAlignConstraint(5, NewPart1, NewPart1.GetPlane("YZ-Plane"), NewPart2, NewPart2.GetPlane("YZ-Plane"))

This follows the same form as the mate constraint function call.

There are similar functions available to add angle, orient and tangent constraints.

Constraints can be added between the following items:
  • Axes
  • Edges
  • Faces
  • Planes
  • Points
  • Vertices
Andy
 

NateLiquidGravity

Alibre Super User
Andy, Is it possible to programmatically find an edge and face name for something made with WizoScript or will this be something that requires a human eye to setup from an opened part?
 

ajayre

Alibre Super User
Andy, Is it possible to programmatically find an edge and face name for something made with WizoScript or will this be something that requires a human eye to setup from an opened part?

Yes, for example:

Code:
MyEdge = Screw.GetEdge("Edge<9>")
MyFace = Screw.GetFace("Face<3>")

The only problem is that when features are added AD can renumber all the faces and edges. However if your script creates something in a predictable way then the numbering used is always the same. For example see this script (created by someone else): http://www.wizotools.com/2016/05/31/iso-4762-bolts/

I think it's probably better to insert reference planes and use those for constraints instead, because they can be named and you know exactly where they are.

Andy
 
Last edited:
Top