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

Constraints to Assembly Planes

Discussion in 'Alibre Script' started by NateLiqGrav, Jun 17, 2019.

  1. NateLiqGrav

    NateLiqGrav Alibre Super User

    I'm trying to add constraints from a part to assembly planes.
    Code:
    assy = CurrentAssembly()
    prt = assy.GetPart('New Part (1)<1>')
    assy.AddAlignConstraint(0, assy, assy.XYPlane, prt, prt.XYPlane)
    I get this error:
    I can constrain an AssemledPart to an AssembledSubAssembly but not the parent assembly. Is there a way this should work?
     
  2. idslk

    idslk Alibre Super User

    Hello Nate,

    i would insert the first part into the assembly using offset and angle, then i would anchor this part or subassembly.
    With the next part or subassembly you can use constraints how you like...
    I think the addAlignContraint awaits (as the failure message and the reference says) an IInstance and the main assembly is not an IInstance of itself...

    Regards
    Stefan
     
  3. NateLiqGrav

    NateLiqGrav Alibre Super User

    Yes that's how I understood the error msg and that's how I worked-around the error too. However doesn't seem right.
     
  4. albie0803

    albie0803 Alibre Super User

    So at the moment you cannot insert a part into an assembly (at any level) and constrain it to a plane in the assembly.
     
  5. NateLiqGrav

    NateLiqGrav Alibre Super User

    That appears to be the case. Perhaps not the assembly's points and axis either.
     
  6. albie0803

    albie0803 Alibre Super User

    Exception:

    Both these lines work in the included script

    Assy.AddMateConstraint(0, Screw, Screw.YZPlane, P1, own_face)
    Assy.AddMateConstraint(0, P1, own_face, Screw, Screw.YZPlane)

    o_O:confused:
     

    Attached Files:

  7. idslk

    idslk Alibre Super User

    Hello albie0803,

    opened a fresh assembly, inserted a demo part and started the downloaded skript.
    got this console output:

    M5
    M5
    Face<9>
    Wuerfel
    M5.0 x 30.0mm SHCS<1>
    Microsoft.Scripting.ArgumentTypeException: expected IInstance, got Part

    ...

    tested it 2 times with same result...

    Regards
    Stefan
     
  8. NateLiqGrav

    NateLiqGrav Alibre Super User

    Requires Beta.
     
  9. NateLiqGrav

    NateLiqGrav Alibre Super User

    Those planes are not 'owned' by the assembly. I'm talking about planes 'owned' by the assembly.
     
  10. idslk

    idslk Alibre Super User

    if you are not on beta, you can try the appended script.
    It's only to test if it works...i changed/added a few lines after the face input...
    So it does not recognize which instance of duplicates is selected(it checks if there are duplicates, but it will take the first part of the list...if somebody has interest...)
    and so on and on...
    Open an new assembly, insert an part (i've made me a cube for this...)and run the script...
    Regards
    Stefan
     

    Attached Files:

  11. NateLiqGrav

    NateLiqGrav Alibre Super User

    My problem is adding constraints directly to an assembly's reference geometry.
    I think this will need to be an enhancement request.
     
  12. idslk

    idslk Alibre Super User

    i understood as said in #2, the #10 script is primary for albie0803 to may he wants to do his script before 2019 is released.
    I think you're right with the enhancement request.

    Regards
    Stefan
     

Share This Page