1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Tutorial: Assemblies in WizoScript

Discussion in 'Tutorials and Tips from the Community' started by ajayre, Oct 9, 2017.

  1. ajayre

    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:

    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
    To put the origin of the part at the origin of the assembly the X, Y and Z locations are all zero. Rotation is given in degrees. Currently only rotation around axes is possible.

    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
     
    cadtec and NateLiqGrav like this.
  2. Lew_Merrick

    Lew_Merrick Alibre Super User

  3. albie0803

    albie0803 Alibre Super User

    works for me
     
  4. ajayre

    ajayre Alibre Super User

    Works for me also.
     
  5. Mark M.

    Mark M. New Member

    This works fine for me. It goes a way toward being able to replicate some of the old "Motion" functionality. Is there any way to have the system respect the constraints associated with the parts that move or rotate? That would be very useful in trying to simulate system motion. Also, I did a quick search but I don't see any "delay" function that makes it easier to see the motion. Does that exist.
     
  6. Lew_Merrick

    Lew_Merrick Alibre Super User

    I believe that I reported something that was (back in early October) an issue with Windows 7. Andy had it "fixed" very shortly thereafter! Just to b clear.
     
  7. ajayre

    ajayre Alibre Super User

    No, the AD API doesn't support it.

    Yes, you can add a delay in python.

    Code:
    import time
    
    # wait for 0.5 seconds
    time.sleep(0.5)
    
    See: https://docs.python.org/2/library/time.html?highlight=sleep#time.sleep

    Andy
     

Share This Page