# Author - Maciej Rogowski
# Copyright 2025 Maciej Rogowski. All rights reserved.
# Description - Creates a mortise and tenon joint between two boards.








































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































import adsk.core



































































































import adsk.fusion



































































































import traceback



































































































import os



































































































import math



































































































import sys



































































































import json



































































































import subprocess



































































































SN46rVt5 = False



































































































LwkC7J6M = 3



































































































BKhfFwk7 = False



































































































if SN46rVt5 and not BKhfFwk7:



































































































    from .library import library  



































































































class H44bB1GG:



































































































    def __init__(Q7B515Ph):



































































































        Q7B515Ph.Ghjt2RRG = None



































































































        Q7B515Ph.Sg5VkTCp = None



































































































        Q7B515Ph.LWDFPN31 = None



































































































        Q7B515Ph.ps3sJ5RT = None



































































































        Q7B515Ph.bF64vM4J = None



































































































        Q7B515Ph.BNSmRj3w = None



































































































        Q7B515Ph.gLP8cVZ4 = None



































































































        Q7B515Ph.hFm22fDd = None



































































































        Q7B515Ph.Lr79LGrP = None



































































































        Q7B515Ph.sSqJdGS2 = None



































































































        Q7B515Ph.QbrrQGbk = None



































































































        Q7B515Ph.J5JBSfmt = None



































































































        Q7B515Ph.gz64kP2J = None



































































































        Q7B515Ph.PSdzp5B5 = None



































































































        Q7B515Ph.LL9wQm1D = None



































































































        Q7B515Ph.GTKz6Dn1 = None



































































































        Q7B515Ph.h3kD3bPH = None



































































































        Q7B515Ph.Q1Wt9542 = None



































































































        Q7B515Ph.dk8l23Jk = None



































































































        Q7B515Ph.R486tm21 = None



































































































        Q7B515Ph.JD2d2QCJ = None



































































































        Q7B515Ph.njdv6vjT = None



































































































        Q7B515Ph.cpvnhgc7 = None



































































































        Q7B515Ph.S68jJm9D = None



































































































        Q7B515Ph.JLPzwfKJ = None



































































































        Q7B515Ph.g21k9PKG = None



































































































        Q7B515Ph.W5GjH93c = None



































































































        Q7B515Ph.zs1STq6T = None



































































































        Q7B515Ph.wGmH5CNj = None



































































































        Q7B515Ph.f7Md1glS = None



































































































        Q7B515Ph.Fsjlw27N = None



































































































        Q7B515Ph.b3v5Ssk4 = None



































































































        Q7B515Ph.bV3M5dz6 = None



































































































        Q7B515Ph.V6vvQ6NG = None



































































































        Q7B515Ph.jR29GP4P = None



































































































        Q7B515Ph.tcB3Hj5T = None



































































































        Q7B515Ph.jQWPbQr7 = None



































































































        Q7B515Ph.Vf7PTk49 = None



































































































        Q7B515Ph.S5PV6c1T = None



































































































        Q7B515Ph.tmZbm648 = None



































































































        Q7B515Ph.JdLw9ZZr = None



































































































        Q7B515Ph.Jj7nd432 = False



































































































        Q7B515Ph.fbk2MbtH = False



































































































def qS7pstp8(hL5pdT5Q, KhMgctKR):



































































































    h4bFr1Tv = adsk.core.InfiniteLine3D.create(hL5pdT5Q, KhMgctKR.normal)



































































































    return KhMgctKR.intersectWithLine(h4bFr1Tv)



































































































def f9fC4mJz(hL5pdT5Q, Z2dvhPJV):



































































































    (jPj3LK8B, fFsP3442, f6dWBd5L) = Z2dvhPJV.getData()



































































































    p73wH6n2 = f6dWBd5L.crossProduct(hL5pdT5Q.vectorTo(fFsP3442))



































































































    PvbM5kkm = f6dWBd5L.crossProduct(p73wH6n2)



































































































    try:



































































































        lM4sP4gM = adsk.core.Plane.create(fFsP3442, PvbM5kkm)



































































































        return qS7pstp8(hL5pdT5Q, lM4sP4gM)



































































































    except Exception:



































































































        return hL5pdT5Q



































































































def RKCnT4ld(QllKbH1m,



































































































                      JNL1B1QF):



































































































    FMTJd1vZ = QllKbH1m.copy()



































































































    try:



































































































        if JNL1B1QF.assemblyContext is not None:



































































































            fv6PNvPN = JNL1B1QF.assemblyContext.transform2



































































































            w556tdnc = fv6PNvPN.copy()



































































































            w556tdnc.invert()



































































































            FMTJd1vZ.transformBy(w556tdnc)



































































































        return FMTJd1vZ



































































































    except Exception:



































































































        qN9pKtLP()



































































































        return QllKbH1m



































































































def m66P7lZB(gBvql29R, FHSjt36z):



































































































    p16lk56G = adsk.core.Point3D.create(0, 0, 0)



































































































    p16lk56G.x = (gBvql29R.x + FHSjt36z.x) / 2



































































































    p16lk56G.y = (gBvql29R.y + FHSjt36z.y) / 2



































































































    p16lk56G.z = (gBvql29R.z + FHSjt36z.z) / 2



































































































    return p16lk56G



































































































class b28F624h:



































































































    global cL62qdlC



































































































    def __init__(Q7B515Ph, hVCstGLf, JMM46Z63):



































































































        Q7B515Ph.BH5d22P4 = None



































































































        Q7B515Ph.QzRqp613 = None



































































































        Q7B515Ph.HF8RG4s8 = None



































































































        Q7B515Ph.mq2pbPMZ = None



































































































        Q7B515Ph.TwtFVk2s = None



































































































        Q7B515Ph.Hr7G3whC = None



































































































        Q7B515Ph.GN1922td = None



































































































        Q7B515Ph.SfP6ZD9t = None



































































































        Q7B515Ph.q8WwJccs = None



































































































        Q7B515Ph.RdlhV9pK = None



































































































        Q7B515Ph.Q2k49HvH = None



































































































        Q7B515Ph.f2FbZpZ7 = None



































































































        DnjsdMPH = None



































































































        Q7B515Ph.f2FbZpZ7 = nT6w4946(hVCstGLf)



































































































        J4d7z9s6 = Q7B515Ph.f2FbZpZ7.edges



































































































        lc7Ckl9K = list(filter(lambda FJSPH4P4: FJSPH4P4.geometry.curveType == adsk.core.Curve3DTypes.Line3DCurveType, J4d7z9s6))



































































































        if not JMM46Z63:



































































































            Q7B515Ph.BH5d22P4 = max(lc7Ckl9K, key=lambda FJSPH4P4: FJSPH4P4.length)



































































































        else:



































































































            Q7B515Ph.BH5d22P4 = min(lc7Ckl9K, key=lambda FJSPH4P4: FJSPH4P4.length)



































































































        kBLr94Rb = cL62qdlC.measureManager



































































































        v2KjNnQ3 = Q7B515Ph.f2FbZpZ7.vertices



































































































        mg26T7QP = 0.0



































































































        for p5B5426F in v2KjNnQ3:



































































































            L71NVqs2 = kBLr94Rb.measureMinimumDistance(p5B5426F, Q7B515Ph.BH5d22P4).value



































































































            if L71NVqs2 > mg26T7QP:



































































































                mg26T7QP = L71NVqs2



































































































                Q7B515Ph.QzRqp613 = p5B5426F



































































































        Q7B515Ph.HF8RG4s8 = mg26T7QP



































































































        DnjsdMPH = f9fC4mJz(Q7B515Ph.QzRqp613.geometry, Q7B515Ph.BH5d22P4.geometry.asInfiniteLine()).vectorTo(Q7B515Ph.QzRqp613.geometry)  



































































































        Q7B515Ph.mq2pbPMZ = Q7B515Ph.BH5d22P4.startVertex.geometry.copy()



































































































        Q7B515Ph.mq2pbPMZ.translateBy(DnjsdMPH)



































































































        Q7B515Ph.TwtFVk2s = Q7B515Ph.BH5d22P4.endVertex.geometry.copy()



































































































        Q7B515Ph.TwtFVk2s.translateBy(DnjsdMPH)



































































































        Q7B515Ph.Hr7G3whC = m66P7lZB(Q7B515Ph.BH5d22P4.startVertex.geometry, Q7B515Ph.mq2pbPMZ)



































































































        Q7B515Ph.GN1922td = m66P7lZB(Q7B515Ph.BH5d22P4.endVertex.geometry, Q7B515Ph.TwtFVk2s)



































































































        Q7B515Ph.SfP6ZD9t = m66P7lZB(Q7B515Ph.Hr7G3whC, Q7B515Ph.GN1922td)



































































































        Q7B515Ph.q8WwJccs = Q7B515Ph.Hr7G3whC.vectorTo(Q7B515Ph.GN1922td)



































































































        Q7B515Ph.q8WwJccs.normalize()



































































































        Q7B515Ph.RdlhV9pK = Q7B515Ph.GN1922td.vectorTo(Q7B515Ph.Hr7G3whC)



































































































        Q7B515Ph.RdlhV9pK.normalize()



































































































        Q7B515Ph.Q2k49HvH = Q7B515Ph.BH5d22P4.length



































































































class RvhPkl5h:



































































































    global p169ZFkB



































































































    def __init__(Q7B515Ph, l1Zpd1h3, cNn3G3L1, mjrj3L5j, lDSDgMJv=False):



































































































        Q7B515Ph.F6MstvvT = l1Zpd1h3



































































































        Q7B515Ph.PCG8phSB = cNn3G3L1



































































































        Q7B515Ph.HQ88c6qz = mjrj3L5j



































































































        Q7B515Ph.HKLCz4v3 = lDSDgMJv



































































































        Q7B515Ph.HVF4495d = None



































































































        Q7B515Ph.hQJQr4T6 = None



































































































        Q7B515Ph.m8DQ2c3J = None



































































































        Q7B515Ph.TfgTwZpm = None



































































































        dKSDFg5V = None



































































































        Q7B515Ph.HVF4495d = l1Zpd1h3.project(cNn3G3L1.BH5d22P4).item(0)  



































































































        dKSDFg5V = l1Zpd1h3.project(cNn3G3L1.QzRqp613).item(0)  



































































































        l1Zpd1h3.isComputeDeferred = True



































































































        qg1cD3PW = RKCnT4ld(cNn3G3L1.mq2pbPMZ, mjrj3L5j)  



































































































        v6TTkCPT = l1Zpd1h3.modelToSketchSpace(qg1cD3PW)



































































































        tmT8Wn9n = RKCnT4ld(cNn3G3L1.TwtFVk2s, mjrj3L5j)  



































































































        PS2D3wbr = l1Zpd1h3.modelToSketchSpace(tmT8Wn9n)



































































































        zgJw9P3m = RKCnT4ld(cNn3G3L1.BH5d22P4.startVertex.geometry, mjrj3L5j)



































































































        F1chksS2 = l1Zpd1h3.modelToSketchSpace(zgJw9P3m)



































































































        dWRL9lqr = RKCnT4ld(cNn3G3L1.BH5d22P4.endVertex.geometry, mjrj3L5j)



































































































        t4cckJR3 = l1Zpd1h3.modelToSketchSpace(dWRL9lqr)



































































































        Dr72rCn8 = l1Zpd1h3.sketchCurves.sketchLines



































































































        Q7B515Ph.hQJQr4T6 = Dr72rCn8.addByTwoPoints(v6TTkCPT, PS2D3wbr)  



































































































        Q7B515Ph.m8DQ2c3J = Dr72rCn8.addByTwoPoints(F1chksS2, v6TTkCPT)  



































































































        Q7B515Ph.TfgTwZpm = Dr72rCn8.addByTwoPoints(t4cckJR3, PS2D3wbr)  



































































































        if lDSDgMJv:



































































































            RNkfHh11 = l1Zpd1h3.geometricConstraints



































































































            try:



































































































                RNkfHh11.addCoincident(dKSDFg5V, Q7B515Ph.hQJQr4T6)



































































































                RNkfHh11.addPerpendicular(Q7B515Ph.HVF4495d, Q7B515Ph.m8DQ2c3J)



































































































                RNkfHh11.addPerpendicular(Q7B515Ph.HVF4495d, Q7B515Ph.TfgTwZpm)



































































































                RNkfHh11.addParallel(Q7B515Ph.HVF4495d, Q7B515Ph.hQJQr4T6)



































































































                RNkfHh11.addCoincident(Q7B515Ph.HVF4495d.startSketchPoint, Q7B515Ph.m8DQ2c3J.startSketchPoint)



































































































                RNkfHh11.addCoincident(Q7B515Ph.HVF4495d.endSketchPoint, Q7B515Ph.TfgTwZpm.startSketchPoint)



































































































                RNkfHh11.addCoincident(Q7B515Ph.hQJQr4T6.startSketchPoint, Q7B515Ph.m8DQ2c3J.endSketchPoint)



































































































                RNkfHh11.addCoincident(Q7B515Ph.hQJQr4T6.endSketchPoint, Q7B515Ph.TfgTwZpm.endSketchPoint)



































































































            except Exception:



































































































                p169ZFkB.messageBox('Unable to add constraints to the geometry.', "Mortise and Tenon")



































































































class cs2VrBgr(RvhPkl5h):



































































































    def __init__(Q7B515Ph,



































































































                 l1Zpd1h3,



































































































                 cNn3G3L1,



































































































                 mjrj3L5j,



































































































                 lDSDgMJv):



































































































        super().__init__(l1Zpd1h3, cNn3G3L1, mjrj3L5j, lDSDgMJv)



































































































    def kkLqGPkv(Q7B515Ph,



































































































                                   pj43FN6D,



































































































                                   V1D1W15N,



































































































                                   cjLL1mfC,



































































































                                   rw4bCR2q,



































































































                                   HrFsPC41,



































































































                                   RtRfj2k4,



































































































                                   Bqsdh1L6,



































































































                                   HRcH2TBZ,



































































































                                   c9m8FFcz,



































































































                                   nmMZj4nq,



































































































                                   TKD8gGM4,



































































































                                   chGf2pt1,



































































































                                   Tmmj4MkK,



































































































                                   tG9894DT):



































































































        Q7B515Ph.WnCkh2Rs = RKCnT4ld(Q7B515Ph.PCG8phSB.SfP6ZD9t, Q7B515Ph.HQ88c6qz)



































































































        Q7B515Ph.QfDfsz9b = Q7B515Ph.m8DQ2c3J



































































































        Hc1TT25P = Q7B515Ph.TfgTwZpm



































































































        if pj43FN6D:



































































































            Q7B515Ph.QfDfsz9b, Hc1TT25P = Hc1TT25P, Q7B515Ph.QfDfsz9b



































































































        if tG9894DT:



































































































            nmMZj4nq, chGf2pt1 = chGf2pt1, nmMZj4nq



































































































            TKD8gGM4, Tmmj4MkK = Tmmj4MkK, TKD8gGM4



































































































        jMVWv3Wn = Q7B515Ph.QfDfsz9b.startSketchPoint.geometry.vectorTo(Hc1TT25P.startSketchPoint.geometry)



































































































        jMVWv3Wn.normalize()



































































































        STrNDm8B = Q7B515Ph.QfDfsz9b.startSketchPoint.geometry.vectorTo(Q7B515Ph.QfDfsz9b.endSketchPoint.geometry)



































































































        STrNDm8B.normalize()



































































































        Dr72rCn8 = Q7B515Ph.F6MstvvT.sketchCurves.sketchLines



































































































        W7CL5jT6 = V1D1W15N + rw4bCR2q + RtRfj2k4



































































































        wlF6VRFb = Q7B515Ph.QfDfsz9b.startSketchPoint.geometry.copy()



































































































        V94g7DD5 = jMVWv3Wn.copy()



































































































        V94g7DD5.scaleBy(W7CL5jT6)



































































































        wlF6VRFb.translateBy(V94g7DD5)



































































































        Tr8735LH = Q7B515Ph.QfDfsz9b.endSketchPoint.geometry.copy()



































































































        Tr8735LH.translateBy(V94g7DD5)



































































































        FkGGvSHS = rw4bCR2q - RtRfj2k4



































































































        kMsbtCzJ = Q7B515Ph.QfDfsz9b.startSketchPoint.geometry.copy()



































































































        wMmpl15H = Q7B515Ph.QfDfsz9b.endSketchPoint.geometry.copy()



































































































        V94g7DD5 = jMVWv3Wn.copy()



































































































        V94g7DD5.scaleBy(FkGGvSHS)



































































































        kMsbtCzJ.translateBy(V94g7DD5)



































































































        wMmpl15H.translateBy(V94g7DD5)



































































































        KRLgKSgd = HRcH2TBZ - nmMZj4nq



































































































        kRj1QsP8 = STrNDm8B.copy()



































































































        kRj1QsP8.scaleBy(-KRLgKSgd)



































































































        kMsbtCzJ.translateBy(kRj1QsP8)



































































































        wlF6VRFb.translateBy(kRj1QsP8)



































































































        cWPT9DCR = HRcH2TBZ - chGf2pt1



































































































        wGLVsFnC = STrNDm8B.copy()



































































































        wGLVsFnC.scaleBy(cWPT9DCR)



































































































        wMmpl15H.translateBy(wGLVsFnC)



































































































        Tr8735LH.translateBy(wGLVsFnC)



































































































        V35586Kc = Dr72rCn8.addByTwoPoints(kMsbtCzJ, wMmpl15H)



































































































        J6sR7Jg7 = Dr72rCn8.addByTwoPoints(wlF6VRFb, Tr8735LH)



































































































        Q7B515Ph.QfDfsz9b.isConstruction = True



































































































        Hc1TT25P.isConstruction = True



































































































        Q7B515Ph.HVF4495d.isConstruction = True



































































































        Q7B515Ph.hQJQr4T6.isConstruction = True



































































































        if Q7B515Ph.HKLCz4v3:



































































































            LLc4tdp1 = Dr72rCn8.addByTwoPoints(V35586Kc.startSketchPoint, J6sR7Jg7.startSketchPoint)



































































































            sKDC9C11 = Dr72rCn8.addByTwoPoints(V35586Kc.endSketchPoint, J6sR7Jg7.endSketchPoint)



































































































        else:



































































































            LLc4tdp1 = Dr72rCn8.addByTwoPoints(V35586Kc.startSketchPoint.geometry, J6sR7Jg7.startSketchPoint.geometry)



































































































            sKDC9C11 = Dr72rCn8.addByTwoPoints(V35586Kc.endSketchPoint.geometry, J6sR7Jg7.endSketchPoint.geometry)



































































































        if Q7B515Ph.HKLCz4v3:



































































































            RNkfHh11 = Q7B515Ph.F6MstvvT.geometricConstraints



































































































            try:



































































































                RNkfHh11.addParallel(Q7B515Ph.HVF4495d, LLc4tdp1)



































































































                RNkfHh11.addParallel(Q7B515Ph.HVF4495d, sKDC9C11)



































































































                RNkfHh11.addPerpendicular(Q7B515Ph.HVF4495d, V35586Kc)



































































































                RNkfHh11.addPerpendicular(Q7B515Ph.HVF4495d, J6sR7Jg7)



































































































                if rw4bCR2q > 0:



































































































                    VdT16426 = f'{HrFsPC41} - ({Bqsdh1L6})'



































































































                else:



































































































                    VdT16426 = "-(" + Bqsdh1L6 + ')'



































































































                kgjZfZSB = f'{cjLL1mfC} + {HrFsPC41} + {Bqsdh1L6}'



































































































                VGcRmHHb = Dr72rCn8.addByTwoPoints(f9fC4mJz(J6sR7Jg7.startSketchPoint.geometry, Q7B515Ph.QfDfsz9b.geometry.asInfiniteLine()), J6sR7Jg7.startSketchPoint)



































































































                VGcRmHHb.isConstruction = True



































































































                RNkfHh11.addParallel(Q7B515Ph.HVF4495d, VGcRmHHb)



































































































                RNkfHh11.addCoincident(VGcRmHHb.startSketchPoint, Q7B515Ph.QfDfsz9b)



































































































                rg65ZgKw = Dr72rCn8.addByTwoPoints(f9fC4mJz(J6sR7Jg7.endSketchPoint.geometry, Q7B515Ph.QfDfsz9b.geometry.asInfiniteLine()), J6sR7Jg7.endSketchPoint)



































































































                rg65ZgKw.isConstruction = True



































































































                RNkfHh11.addParallel(Q7B515Ph.HVF4495d, rg65ZgKw)



































































































                RNkfHh11.addCoincident(rg65ZgKw.startSketchPoint, Q7B515Ph.QfDfsz9b)



































































































                Q7B515Ph.qcFKqTn3(VGcRmHHb.startSketchPoint, V35586Kc.startSketchPoint, VdT16426)



































































































                Q7B515Ph.qcFKqTn3(VGcRmHHb.startSketchPoint, J6sR7Jg7.startSketchPoint, kgjZfZSB, 2, 2)



































































































                J57MTsQ7 = Q7B515Ph.F6MstvvT.sketchPoints



































































































                S1VZ4TBv = Q7B515Ph.QfDfsz9b.startSketchPoint.geometry.copy()



































































































                FRVQ3FML = STrNDm8B.copy()



































































































                FRVQ3FML.scaleBy(nmMZj4nq)



































































































                S1VZ4TBv.translateBy(FRVQ3FML)



































































































                gt2VGv7K = J57MTsQ7.add(S1VZ4TBv)



































































































                RNkfHh11.addCoincident(gt2VGv7K, Q7B515Ph.QfDfsz9b)



































































































                Q7B515Ph.qcFKqTn3(Q7B515Ph.QfDfsz9b.startSketchPoint, gt2VGv7K, TKD8gGM4, 0, 1.5)



































































































                Q7B515Ph.qcFKqTn3(gt2VGv7K, VGcRmHHb.startSketchPoint, c9m8FFcz, 0, 1)



































































































                WslbZV87 = Q7B515Ph.QfDfsz9b.endSketchPoint.geometry.copy()



































































































                T53PNRjD = STrNDm8B.copy()



































































































                T53PNRjD.scaleBy(-chGf2pt1)



































































































                WslbZV87.translateBy(T53PNRjD)



































































































                hCS4FvWG = J57MTsQ7.add(WslbZV87)



































































































                RNkfHh11.addCoincident(hCS4FvWG, Q7B515Ph.QfDfsz9b)



































































































                Q7B515Ph.qcFKqTn3(Q7B515Ph.QfDfsz9b.endSketchPoint, hCS4FvWG, Tmmj4MkK, 0, 1.5)



































































































                Q7B515Ph.qcFKqTn3(hCS4FvWG, rg65ZgKw.startSketchPoint, c9m8FFcz, 0, 1)



































































































            except Exception:



































































































                p169ZFkB.messageBox('Unable to add constraints to the geometry.', "Mortise and Tenon")



































































































        Q7B515Ph.F6MstvvT.isComputeDeferred = False



































































































    def qcFKqTn3(Q7B515Ph, qfg5TB5G, tg6S3v74, pW8Tkn1k, q5PMJ1Z3=1.0, RSdp181s=1.0):



































































































        l1Zpd1h3 = qfg5TB5G.parentSketch



































































































        if not qfg5TB5G.geometry.isEqualTo(tg6S3v74.geometry):



































































































            d6bvJtg5 = tg6S3v74.geometry.copy()



































































































            d6bvJtg5.x = d6bvJtg5.x + q5PMJ1Z3



































































































            d6bvJtg5.y = d6bvJtg5.y + RSdp181s



































































































            stKQdJHS = l1Zpd1h3.sketchDimensions.addDistanceDimension(qfg5TB5G, tg6S3v74, adsk.fusion.DimensionOrientations.AlignedDimensionOrientation, d6bvJtg5)  



































































































            stKQdJHS.parameter.expression = pW8Tkn1k



































































































        else:



































































































            l1Zpd1h3.geometricConstraints.addCoincident(qfg5TB5G, tg6S3v74)



































































































cL62qdlC = None



































































































p169ZFkB = None



































































































B5jc69Kk = None



































































































P6KQF3wm = None



































































































ZwNS2R4W = None



































































































lMB54F3t = None



































































































gp2rCsr4 = None



































































































kcPDHw12 = False



































































































PdGGWvR1 = False



































































































rcJ7r114 = False



































































































CL93gkpW = False



































































































hFbJcsRM = None



































































































kgmD6nNg = True



































































































cH5Kn9lM = None



































































































thT57b72 = None



































































































p1wP7Jl7 = []



































































































wq6D3162 = []



































































































def qN9pKtLP(n3n45Dsw = None):



































































































    global p169ZFkB



































































































    if n3n45Dsw is None:



































































































        n3n45Dsw = p169ZFkB



































































































    if n3n45Dsw:



































































































        n3n45Dsw.messageBox('Failed:\n{}'.format(traceback.format_exc()), "Mortise and Tenon")



































































































def gc2556tf(T1S1T2N6, BTstZLfP):



































































































    return T1S1T2N6 if T1S1T2N6 is not None else BTstZLfP



































































































def nT6w4946(hSzzCCB7):



































































































    global cL62qdlC



































































































    try:



































































































        n4vcQHR7 = hSzzCCB7.body.parentComponent



































































































        qzLPt3WM = cL62qdlC.activeProduct.rootComponent  



































































































        pW3K5QJn = qzLPt3WM.allOccurrencesByComponent(n4vcQHR7)



































































































        if pW3K5QJn.count > 1:



































































































            return hSzzCCB7.nativeObject.createForAssemblyContext(pW3K5QJn.item(0))



































































































        return hSzzCCB7



































































































    except Exception:



































































































        qN9pKtLP()



































































































def JqKMTZvQ():



































































































    global cL62qdlC



































































































    global p169ZFkB



































































































    cL62qdlC = adsk.core.Application.get()



































































































    p169ZFkB = cL62qdlC.userInterface



































































































def run(P72dkcWf):



































































































    global cL62qdlC



































































































    global p169ZFkB



































































































    global thT57b72



































































































    global p1wP7Jl7



































































































    global kcPDHw12



































































































    try:



































































































        JqKMTZvQ()



































































































        Gc3KVNck = p169ZFkB.commandDefinitions



































































































        bpMvcrV9 = p169ZFkB.commandDefinitions.itemById('MortiseAndTenonMRButtonDefIdPython')



































































































        if bpMvcrV9:



































































































            bpMvcrV9.deleteMe()



































































































        CmpSdG4r = p169ZFkB.allToolbarPanels.itemById('SolidModifyPanel')



































































































        BGftzK63 = CmpSdG4r.controls.itemById('MortiseAndTenonMRButtonDefIdPython')



































































































        if BGftzK63:



































































































            BGftzK63.deleteMe()



































































































        RJ41rCB9 = Gc3KVNck.addButtonDefinition('MortiseAndTenonMRButtonDefIdPython',



































































































                                              'Mortise and Tenon',



































































































                                              'Creates a mortise and tenon joint between two boards.',



































































































                                              './Resources')



































































































        qS9qP3k1 = BPdg8Hbp()



































































































        RJ41rCB9.commandCreated.add(qS9qP3k1)



































































































        thT57b72 = qS9qP3k1



































































































        CmpSdG4r = p169ZFkB.allToolbarPanels.itemById('SolidModifyPanel')



































































































        CmpSdG4r.controls.addCommand(RJ41rCB9)



































































































        kcPDHw12 = mqN834w4()



































































































    except Exception:



































































































        qN9pKtLP()



































































































def stop(P72dkcWf):



































































































    global p169ZFkB



































































































    global thT57b72



































































































    global p1wP7Jl7



































































































    global wq6D3162



































































































    global P6KQF3wm



































































































    global ZwNS2R4W



































































































    global lMB54F3t



































































































    global gp2rCsr4



































































































    global hFbJcsRM



































































































    try:



































































































        bpMvcrV9 = p169ZFkB.commandDefinitions.itemById('MortiseAndTenonMRButtonDefIdPython')



































































































        if bpMvcrV9:



































































































            bpMvcrV9.deleteMe()



































































































        CmpSdG4r = p169ZFkB.allToolbarPanels.itemById('SolidModifyPanel')



































































































        BGftzK63 = CmpSdG4r.controls.itemById('MortiseAndTenonMRButtonDefIdPython')



































































































        if BGftzK63:



































































































            BGftzK63.deleteMe()



































































































        thT57b72 = None  



































































































        p1wP7Jl7 = []



































































































        wq6D3162 = []



































































































        P6KQF3wm = None



































































































        ZwNS2R4W = None  



































































































        lMB54F3t = None



































































































        gp2rCsr4 = None  



































































































        hFbJcsRM = None  



































































































    except Exception:



































































































        qN9pKtLP()



































































































def mqN834w4():



































































































    try:



































































































        Zr26b2kG = os.path.dirname(os.path.realpath(__file__))



































































































        LqDQ61fh = Zr26b2kG + '/set.set'



































































































        BkNWGgDL = Zr26b2kG + '/options.set'



































































































        if os.path.isfile(LqDQ61fh) and os.path.isfile(BkNWGgDL):



































































































            if os.path.getsize(LqDQ61fh) == 0 or os.path.getsize(BkNWGgDL) == 0:



































































































                return False



































































































            Tr2h46vZ = abs(os.path.getmtime(LqDQ61fh) - os.path.getmtime(BkNWGgDL))



































































































            if Tr2h46vZ >= 2.4 and Tr2h46vZ <= 2.8:



































































































                return True



































































































        return False



































































































    except Exception:



































































































        qN9pKtLP()



































































































def wC12Jb16():



































































































    import time



































































































    try:



































































































        Zr26b2kG = os.path.dirname(os.path.realpath(__file__))



































































































        LqDQ61fh = Zr26b2kG + '/set.set'



































































































        with open(LqDQ61fh, 'w') as R7DB17pB:



































































































            Ls4HjdF8 = 'True'



































































































            R7DB17pB.write(Ls4HjdF8)



































































































        time.sleep(2.5)



































































































        BkNWGgDL = Zr26b2kG + '/options.set'



































































































        with open(BkNWGgDL, 'w') as lbwn3335:



































































































            Ls4HjdF8 = 'True'



































































































            lbwn3335.write(Ls4HjdF8)



































































































    except Exception:



































































































        qN9pKtLP()



































































































def tcr2H9Mv(g2cPPlpW):



































































































    return chr(int(g2cPPlpW) + 65)



































































































def vQTlJ4cM(T9flJVvR):



































































































    return str(ord(T9flJVvR) - 65)



































































































def CL3tjmwr(Ls4HjdF8):



































































































    if len(Ls4HjdF8) >= 10:



































































































        if Ls4HjdF8[8] == 'C':



































































































            D45BZ5Nl = str((int(vQTlJ4cM(Ls4HjdF8[1])) + int(vQTlJ4cM(Ls4HjdF8[5])) + int(Ls4HjdF8[2]) + int(vQTlJ4cM(Ls4HjdF8[0])) + int(vQTlJ4cM(Ls4HjdF8[4])) + int(Ls4HjdF8[3]) + 5730) * 2)



































































































            if Ls4HjdF8[6] == D45BZ5Nl[-3]:



































































































                if Ls4HjdF8[7] == D45BZ5Nl[-2]:



































































































                    if vQTlJ4cM(Ls4HjdF8[9]) == D45BZ5Nl[-1]:



































































































                        return True



































































































    return False



































































































def SGlFLNcV(qd7LfHBp):



































































































    import pickle



































































































    try:



































































































        Zr26b2kG = os.path.dirname(os.path.realpath(__file__))



































































































        jBRsdq7q = Zr26b2kG + '/settings.set'



































































































        gm3ttsd7 = open(jBRsdq7q, 'wb')



































































































        pickle.dump(qd7LfHBp, gm3ttsd7)



































































































        gm3ttsd7.close()



































































































    except Exception:



































































































        qN9pKtLP()



































































































def GKvgKwgK():



































































































    import pickle



































































































    try:



































































































        qd7LfHBp = []



































































































        Zr26b2kG = os.path.dirname(os.path.realpath(__file__))



































































































        jBRsdq7q = Zr26b2kG + '/settings.set'



































































































        gm3ttsd7 = open(jBRsdq7q, 'rb')



































































































        if os.path.getsize(jBRsdq7q) > 0:



































































































            qd7LfHBp = pickle.load(gm3ttsd7)



































































































            gm3ttsd7.close()



































































































        return qd7LfHBp



































































































    except Exception:



































































































        qN9pKtLP()



































































































def F6Dn2jTn(JNL1B1QF):



































































































    try:



































































































        r2c54Jd4 = JNL1B1QF



































































































        GtdqBD6t = False



































































































        for qPf1Nk77 in range(1000):



































































































            if r2c54Jd4.assemblyContext:



































































































                if r2c54Jd4.assemblyContext.isReferencedComponent:



































































































                    GtdqBD6t = True



































































































                r2c54Jd4 = r2c54Jd4.assemblyContext



































































































            else:



































































































                break



































































































        return GtdqBD6t



































































































    except Exception:



































































































        qN9pKtLP()



































































































def Fnljrl6Z(QllKbH1m,



































































































                    JNL1B1QF):



































































































    FMTJd1vZ = QllKbH1m.copy()



































































































    try:



































































































        if JNL1B1QF.assemblyContext is not None:



































































































            fv6PNvPN = JNL1B1QF.assemblyContext.transform2



































































































            FMTJd1vZ.transformBy(fv6PNvPN)



































































































        return FMTJd1vZ



































































































    except Exception:



































































































        qN9pKtLP()



































































































        return QllKbH1m



































































































def s27JHV6W(Q1fl6Wll,



































































































                direction,



































































































                p2pG57Hc,



































































































                lDSDgMJv,



































































































                pW8Tkn1k):



































































































    l1Zpd1h3 = Q1fl6Wll.parentSketch



































































































    V94g7DD5 = direction.copy()



































































































    V94g7DD5.normalize()



































































































    V94g7DD5.scaleBy(p2pG57Hc)



































































































    gC48Jq3l = Q1fl6Wll.geometry.startPoint



































































































    gC48Jq3l.translateBy(V94g7DD5)



































































































    sV1v6l22 = Q1fl6Wll.geometry.endPoint



































































































    sV1v6l22.translateBy(V94g7DD5)



































































































    s27JHV6W = l1Zpd1h3.sketchCurves.sketchLines.addByTwoPoints(gC48Jq3l, sV1v6l22)



































































































    if lDSDgMJv:



































































































        RNkfHh11 = l1Zpd1h3.geometricConstraints



































































































        nvHFL222 = m66P7lZB(Q1fl6Wll.startSketchPoint.geometry, Q1fl6Wll.endSketchPoint.geometry)



































































































        cGppZ3Hh = m66P7lZB(s27JHV6W.startSketchPoint.geometry, s27JHV6W.endSketchPoint.geometry)



































































































        KZmFwmZ6 = l1Zpd1h3.sketchCurves.sketchLines.addByTwoPoints(nvHFL222, cGppZ3Hh)



































































































        RNkfHh11.addMidPoint(KZmFwmZ6.startSketchPoint, Q1fl6Wll)



































































































        RNkfHh11.addMidPoint(KZmFwmZ6.endSketchPoint, s27JHV6W)



































































































        KZmFwmZ6.isConstruction = True



































































































        RNkfHh11.addPerpendicular(Q1fl6Wll, KZmFwmZ6)



































































































        RNkfHh11.addParallel(Q1fl6Wll, s27JHV6W)



































































































        RNkfHh11.addEqual(Q1fl6Wll, s27JHV6W)



































































































        d6bvJtg5 = s27JHV6W.startSketchPoint.geometry.copy()



































































































        d6bvJtg5.x = d6bvJtg5.x + 1



































































































        d6bvJtg5.y = d6bvJtg5.y + 1



































































































        T3V1tTrr = l1Zpd1h3.sketchDimensions.addOffsetDimension(Q1fl6Wll, s27JHV6W.startSketchPoint, d6bvJtg5)  



































































































        T3V1tTrr.parameter.expression = pW8Tkn1k



































































































    return s27JHV6W



































































































def PlQW3HjD(wS1Cdn33):



































































































    global ZwNS2R4W



































































































    global hFbJcsRM



































































































    try:



































































































        hmgtw4hP = ZwNS2R4W.LWDFPN31.selection(0).entity  



































































































        hSzzCCB7 = ZwNS2R4W.ps3sJ5RT.selection(0).entity  



































































































        if wS1Cdn33 and ZwNS2R4W.V6vvQ6NG.value and ZwNS2R4W.jQWPbQr7.value:



































































































            SCCnSTpn = cL62qdlC.activeProduct  



































































































            qzLPt3WM = SCCnSTpn.rootComponent



































































































            hmgtw4hP.isLightBulbOn = False



































































































            hmgtw4hP = hmgtw4hP.copyToComponent(gc2556tf(hmgtw4hP.assemblyContext, qzLPt3WM))



































































































            Q66BPtdt = hSzzCCB7.body



































































































            Q66BPtdt = Q66BPtdt.copyToComponent(gc2556tf(Q66BPtdt.assemblyContext, qzLPt3WM))



































































































            for j7Pv4j7F in Q66BPtdt.faces:



































































































                if round(j7Pv4j7F.centroid.x, 5) == round(hSzzCCB7.centroid.x, 5) and round(j7Pv4j7F.centroid.y, 5) == round(hSzzCCB7.centroid.y, 5) and round(j7Pv4j7F.centroid.z, 5) == round(hSzzCCB7.centroid.z, 5) and round(j7Pv4j7F.area, 5) == round(hSzzCCB7.area, 5):



































































































                    hSzzCCB7.body.isLightBulbOn = False



































































































                    hSzzCCB7 = j7Pv4j7F



































































































                    break



































































































        GShWQJjZ = ZwNS2R4W.wGmH5CNj.value



































































































        DKM6RJZk = ZwNS2R4W.bF64vM4J.expression



































































































        pj43FN6D = ZwNS2R4W.gz64kP2J.value



































































































        V1D1W15N = 0



































































































        cjLL1mfC = ""



































































































        QclPWTn1 = 0



































































































        wgJ26kdV = ""



































































































        if ZwNS2R4W.JdLw9ZZr.value is False:



































































































            V1D1W15N = ZwNS2R4W.BNSmRj3w.value



































































































            cjLL1mfC = ZwNS2R4W.BNSmRj3w.expression



































































































        else:



































































































            QclPWTn1 = ZwNS2R4W.gLP8cVZ4.value



































































































            wgJ26kdV = ZwNS2R4W.gLP8cVZ4.expression



































































































        tPBR4wK3 = ZwNS2R4W.Lr79LGrP.value



































































































        wV47VGgp = ZwNS2R4W.Lr79LGrP.expression



































































































        rw4bCR2q = ZwNS2R4W.sSqJdGS2.value



































































































        HrFsPC41 = ZwNS2R4W.sSqJdGS2.expression



































































































        rKvPh9PQ = ZwNS2R4W.QbrrQGbk.value



































































































        nGMd4MTf = ZwNS2R4W.QbrrQGbk.expression



































































































        K5b17rzw = ZwNS2R4W.J5JBSfmt.value



































































































        T37BP79l = ZwNS2R4W.PSdzp5B5.value



































































































        SV2fMr1T = ZwNS2R4W.PSdzp5B5.expression



































































































        RtRfj2k4 = ZwNS2R4W.h3kD3bPH.value



































































































        Bqsdh1L6 = ZwNS2R4W.h3kD3bPH.expression



































































































        HRcH2TBZ = ZwNS2R4W.Q1Wt9542.value



































































































        c9m8FFcz = ZwNS2R4W.Q1Wt9542.expression



































































































        if ZwNS2R4W.b3v5Ssk4.value:



































































































            Q49sV3bj = ZwNS2R4W.dk8l23Jk.expression



































































































        else:



































































































            Q49sV3bj = '0'



































































































        Tft31kG6 = ZwNS2R4W.V6vvQ6NG.value



































































































        G43PQK2z = ZwNS2R4W.W5GjH93c.value



































































































        if Tft31kG6:



































































































            s5SW75K2 = ZwNS2R4W.W5GjH93c.expression



































































































        else:



































































































            s5SW75K2 = '0'



































































































        hg4lQqsk = ZwNS2R4W.jQWPbQr7.value



































































































        if hg4lQqsk:



































































































            P6ns3lS7 = ZwNS2R4W.LL9wQm1D.value



































































































            tb51gqV4 = ZwNS2R4W.LL9wQm1D.expression



































































































        else:



































































































            P6ns3lS7 = 0



































































































            tb51gqV4 = '0'



































































































        KSJ8qwlW = ZwNS2R4W.Vf7PTk49.value



































































































        if KSJ8qwlW:



































































































            nmMZj4nq = ZwNS2R4W.JD2d2QCJ.value



































































































            TKD8gGM4 = ZwNS2R4W.JD2d2QCJ.expression



































































































            chGf2pt1 = ZwNS2R4W.cpvnhgc7.value



































































































            Tmmj4MkK = ZwNS2R4W.cpvnhgc7.expression



































































































            tG9894DT = ZwNS2R4W.JLPzwfKJ.value



































































































        else:



































































































            nmMZj4nq = 0



































































































            TKD8gGM4 = '0'



































































































            chGf2pt1 = 0



































































































            Tmmj4MkK = '0'



































































































            tG9894DT = False



































































































        if PdGGWvR1 and rcJ7r114:



































































































            SqnQ5RH5 = False



































































































        else:



































































































            SqnQ5RH5 = ZwNS2R4W.bV3M5dz6.value



































































































        r5pqdRpv = ZwNS2R4W.JdLw9ZZr.value



































































































        Q8RLfLHm(wS1Cdn33,



































































































                                    hmgtw4hP,



































































































                                    hSzzCCB7,



































































































                                    GShWQJjZ,



































































































                                    DKM6RJZk,



































































































                                    pj43FN6D,



































































































                                    V1D1W15N,



































































































                                    cjLL1mfC,



































































































                                    QclPWTn1,



































































































                                    wgJ26kdV,



































































































                                    tPBR4wK3,



































































































                                    wV47VGgp,



































































































                                    rw4bCR2q,



































































































                                    HrFsPC41,



































































































                                    rKvPh9PQ,



































































































                                    nGMd4MTf,



































































































                                    K5b17rzw,



































































































                                    T37BP79l,



































































































                                    SV2fMr1T,



































































































                                    RtRfj2k4,



































































































                                    Bqsdh1L6,



































































































                                    HRcH2TBZ,



































































































                                    c9m8FFcz,



































































































                                    Q49sV3bj,



































































































                                    s5SW75K2,



































































































                                    P6ns3lS7,



































































































                                    tb51gqV4,



































































































                                    nmMZj4nq,



































































































                                    TKD8gGM4,



































































































                                    chGf2pt1,



































































































                                    Tmmj4MkK,



































































































                                    tG9894DT,



































































































                                    SqnQ5RH5,



































































































                                    r5pqdRpv,



































































































                                    KSJ8qwlW,



































































































                                    Tft31kG6,



































































































                                    G43PQK2z,



































































































                                    hg4lQqsk,



































































































                                    hFbJcsRM)



































































































    except Exception:



































































































        qN9pKtLP()



































































































def Q8RLfLHm(wS1Cdn33,



































































































                                hmgtw4hP,



































































































                                hSzzCCB7,



































































































                                GShWQJjZ,



































































































                                DKM6RJZk,



































































































                                pj43FN6D,



































































































                                V1D1W15N,



































































































                                cjLL1mfC,



































































































                                QclPWTn1,



































































































                                wgJ26kdV,



































































































                                tPBR4wK3,



































































































                                wV47VGgp,



































































































                                rw4bCR2q,



































































































                                HrFsPC41,



































































































                                rKvPh9PQ,



































































































                                nGMd4MTf,



































































































                                K5b17rzw,



































































































                                T37BP79l,



































































































                                SV2fMr1T,



































































































                                RtRfj2k4,



































































































                                Bqsdh1L6,



































































































                                HRcH2TBZ,



































































































                                c9m8FFcz,



































































































                                Q49sV3bj,



































































































                                s5SW75K2,



































































































                                P6ns3lS7,



































































































                                tb51gqV4,



































































































                                nmMZj4nq,



































































































                                TKD8gGM4,



































































































                                chGf2pt1,



































































































                                Tmmj4MkK,



































































































                                tG9894DT,



































































































                                SqnQ5RH5,



































































































                                r5pqdRpv,



































































































                                KSJ8qwlW,



































































































                                Tft31kG6,



































































































                                G43PQK2z,



































































































                                hg4lQqsk,



































































































                                cNn3G3L1):



































































































    global cL62qdlC



































































































    global p169ZFkB



































































































    try:



































































































        SCCnSTpn = cL62qdlC.activeProduct  



































































































        qzLPt3WM = SCCnSTpn.rootComponent



































































































        lKGv9Qfm = hSzzCCB7.body.parentComponent



































































































        kws7kMP6 = qzLPt3WM.allOccurrencesByComponent(lKGv9Qfm)



































































































        if kws7kMP6.count > 1:



































































































            hSzzCCB7 = hSzzCCB7.nativeObject.createForAssemblyContext(kws7kMP6.item(0))



































































































        n4vcQHR7 = hSzzCCB7.body.parentComponent



































































































        VJ3d1F2q = n4vcQHR7.constructionPlanes



































































































        jm3PcK9l = VJ3d1F2q.createInput()



































































































        L76t2kFc = adsk.core.ValueInput.createByReal(0.0)



































































































        jm3PcK9l.setByOffset(hSzzCCB7, L76t2kFc)



































































































        KhMgctKR = VJ3d1F2q.add(jm3PcK9l)



































































































        if not wS1Cdn33:



































































































            KhMgctKR.name = 'MT Plane'



































































































        nb9q224D = n4vcQHR7.sketches



































































































        l1Zpd1h3 = nb9q224D.add(KhMgctKR)



































































































        l1Zpd1h3.name = 'Tenon'



































































































        if not SN46rVt5:



































































































            l1Zpd1h3.isLightBulbOn = False



































































































        if K5b17rzw:



































































































            rKvPh9PQ = rw4bCR2q



































































































        fDD1v5nR = hmgtw4hP.parentComponent



































































































        bK1VLDR3 = None



































































































        ZZmcnsR2 = None



































































































        ScPTnQ19 = None



































































































        l1Nb4dbj = None



































































































        BgQ76NNB = None



































































































        kZFsZSFq = None



































































































        Z463373z = None



































































































        Cj6vGpgw = False



































































































        H7PBt8QZ = cs2VrBgr(l1Zpd1h3,



































































































                                                     cNn3G3L1,



































































































                                                     cNn3G3L1.f2FbZpZ7,



































































































                                                     not wS1Cdn33 and GShWQJjZ)



































































































        vzpWG4J8 = H7PBt8QZ.HVF4495d



































































































        GbFwtKLw = H7PBt8QZ.hQJQr4T6



































































































        if tG9894DT:



































































































            vzpWG4J8, GbFwtKLw = GbFwtKLw, vzpWG4J8



































































































        if tPBR4wK3 > 1:



































































































            if r5pqdRpv:



































































































                V1D1W15N = (vzpWG4J8.length - rw4bCR2q - rKvPh9PQ - QclPWTn1 * (tPBR4wK3 - 1)) / tPBR4wK3



































































































                if K5b17rzw:



































































































                    cjLL1mfC = f'({vzpWG4J8.length * 10}mm - 2 * ({HrFsPC41}) - ({wgJ26kdV}) * ({wV47VGgp} - 1)) / ({wV47VGgp})'



































































































                else:



































































































                    cjLL1mfC = f'({vzpWG4J8.length * 10}mm - ({HrFsPC41}) - ({nGMd4MTf}) - ({wgJ26kdV}) * ({wV47VGgp} - 1)) / ({wV47VGgp})'



































































































        if not wS1Cdn33 and GShWQJjZ:



































































































            kP5kGthF = SCCnSTpn.userParameters



































































































            TZMlggrS = SCCnSTpn.unitsManager.defaultLengthUnits



































































































            vSlT3761 = 'MT'



































































































            R8MW5z33 = 'Width'



































































































            dffRs2fq = 1



































































































            while dffRs2fq < 1000:



































































































                Ts474JDS = vSlT3761 + str(dffRs2fq) + R8MW5z33



































































































                if kP5kGthF.itemByName(Ts474JDS) is not None:



































































































                    dffRs2fq += 1



































































































                else:



































































































                    break



































































































            if tPBR4wK3 > 1:



































































































                z6R3LVzd = adsk.core.ValueInput.createByReal(vzpWG4J8.length)



































































































                S5B59jrP = kP5kGthF.add(Ts474JDS, z6R3LVzd, TZMlggrS, '')



































































































                S5B59jrP.attributes.add("MortiseAndTenon", 'sketchLineEntityToken', vzpWG4J8.entityToken)



































































































            nZt6sll7 = DzS53zST("MT", dffRs2fq, 'Depth', DKM6RJZk, TZMlggrS)



































































































            DKM6RJZk = nZt6sll7.name



































































































            if tPBR4wK3 > 1:



































































































                d6wC654q = ''



































































































                LhJg4m3V = DzS53zST("MT", dffRs2fq, 'NumberOfTenons', wV47VGgp, d6wC654q)



































































































                wV47VGgp = LhJg4m3V.name



































































































            if rw4bCR2q > 0:



































































































                if not (RtRfj2k4 == rw4bCR2q):



































































































                    HHlN567q = DzS53zST("MT", dffRs2fq, 'Offset1', HrFsPC41, TZMlggrS)



































































































                    HrFsPC41 = HHlN567q.name



































































































            else:



































































































                HrFsPC41 = "0"



































































































            if not K5b17rzw and tPBR4wK3 > 1:



































































































                wv5DLBdw = DzS53zST("MT", dffRs2fq, 'Offset2', nGMd4MTf, TZMlggrS)



































































































                nGMd4MTf = wv5DLBdw.name



































































































            if T37BP79l > 0:



































































































                jg78Hd5D = DzS53zST("MT", dffRs2fq, 'FilletRadius', SV2fMr1T, TZMlggrS)



































































































                SV2fMr1T = jg78Hd5D.name



































































































            else:



































































































                SV2fMr1T = "0"



































































































            if P6ns3lS7 > 0:



































































































                c976PR4j = DzS53zST("MT", dffRs2fq, 'InnerFilletRadius', tb51gqV4, TZMlggrS)



































































































                tb51gqV4 = c976PR4j.name



































































































            else:



































































































                tb51gqV4 = "0"



































































































            if not (RtRfj2k4 == rw4bCR2q):



































































































                G3kZdKZ7 = DzS53zST("MT", dffRs2fq, 'LengthOffset', Bqsdh1L6, TZMlggrS)



































































































                Bqsdh1L6 = G3kZdKZ7.name



































































































            if HRcH2TBZ > 0:



































































































                Z1pq2hsW = DzS53zST("MT", dffRs2fq, 'ThicknessOffset', c9m8FFcz, TZMlggrS)



































































































                c9m8FFcz = Z1pq2hsW.name



































































































            else:



































































































                c9m8FFcz = "0"



































































































            qglwW2Qg = DzS53zST("MT", dffRs2fq, 'DepthOffset', Q49sV3bj, TZMlggrS)



































































































            Q49sV3bj = qglwW2Qg.name



































































































            if KSJ8qwlW:



































































































                if nmMZj4nq > 0:



































































































                    RgM3l6wF = DzS53zST("MT", dffRs2fq, 'TenonOffset1', TKD8gGM4, TZMlggrS)



































































































                    TKD8gGM4 = RgM3l6wF.name



































































































                else:



































































































                    TKD8gGM4 = "0"



































































































                if chGf2pt1 > 0:



































































































                    jFWZSl7F = DzS53zST("MT", dffRs2fq, 'TenonOffset2', Tmmj4MkK, TZMlggrS)



































































































                    Tmmj4MkK = jFWZSl7F.name



































































































                else:



































































































                    Tmmj4MkK = "0"



































































































            if Tft31kG6 and G43PQK2z != 0:



































































































                Ts4576f2 = DzS53zST("MT", dffRs2fq, 'DovetailAngle', f'{s5SW75K2}', 'deg')



































































































                s5SW75K2 = Ts4576f2.name



































































































            else:



































































































                s5SW75K2 = "0"



































































































            if r5pqdRpv and tPBR4wK3 > 1:



































































































                CVVFp5PZ = DzS53zST("MT", dffRs2fq, 'Spacing', wgJ26kdV, TZMlggrS)



































































































                wgJ26kdV = CVVFp5PZ.name



































































































                if K5b17rzw:



































































































                    cjLL1mfC = f'({S5B59jrP.name} - 2 * ({HrFsPC41}) - ({wgJ26kdV}) * ({wV47VGgp} - 1)) / ({wV47VGgp})'



































































































                else:



































































































                    cjLL1mfC = f'({S5B59jrP.name} - ({HrFsPC41}) - ({nGMd4MTf}) - ({wgJ26kdV}) * ({wV47VGgp} - 1)) / ({wV47VGgp})'



































































































            if not r5pqdRpv:



































































































                fkqn1hH7 = DzS53zST("MT", dffRs2fq, 'Length', cjLL1mfC, TZMlggrS)



































































































                cjLL1mfC = fkqn1hH7.name



































































































        if KSJ8qwlW:



































































































            if cNn3G3L1.HF8RG4s8 - nmMZj4nq - chGf2pt1 <= 0.0001:



































































































                l1Zpd1h3.deleteMe()



































































































                KhMgctKR.deleteMe()



































































































                return



































































































        if tPBR4wK3 > 1:



































































































            j7tvrGCM = (cNn3G3L1.Q2k49HvH - rw4bCR2q - rKvPh9PQ - V1D1W15N) / (tPBR4wK3 - 1)



































































































        else:



































































































            if K5b17rzw:



































































































                rw4bCR2q = (cNn3G3L1.Q2k49HvH - V1D1W15N) / 2



































































































        cq2jKw1L = RKCnT4ld(cNn3G3L1.SfP6ZD9t, cNn3G3L1.f2FbZpZ7)  



































































































        WF42C56w = l1Zpd1h3.modelToSketchSpace(cq2jKw1L)



































































































        Jl17LcHz = WF42C56w



































































































        p8WGG6wf = H7PBt8QZ.m8DQ2c3J



































































































        ZV62h65l = H7PBt8QZ.TfgTwZpm



































































































        if pj43FN6D:



































































































            p8WGG6wf, ZV62h65l = ZV62h65l, p8WGG6wf



































































































        H7PBt8QZ.kkLqGPkv(pj43FN6D,



































































































                                                V1D1W15N,



































































































                                                cjLL1mfC,



































































































                                                rw4bCR2q,



































































































                                                HrFsPC41,



































































































                                                RtRfj2k4=0,



































































































                                                Bqsdh1L6="0",



































































































                                                HRcH2TBZ=0,



































































































                                                c9m8FFcz="0",



































































































                                                nmMZj4nq=nmMZj4nq,



































































































                                                TKD8gGM4=TKD8gGM4,



































































































                                                chGf2pt1=chGf2pt1,



































































































                                                Tmmj4MkK=Tmmj4MkK,



































































































                                                tG9894DT=tG9894DT)



































































































        jk46Pfrg = adsk.core.ValueInput.createByString("0 deg")



































































































        z3GTkTjj = adsk.core.ValueInput.createByString(f'({DKM6RJZk}) + ({Q49sV3bj})')



































































































        w5VfBq9C = adsk.core.ValueInput.createByString(DKM6RJZk)



































































































        s73sz8jv = adsk.fusion.DistanceExtentDefinition.create(z3GTkTjj)



































































































        nS45KT97 = adsk.fusion.DistanceExtentDefinition.create(w5VfBq9C)



































































































        Fh6pZLj2 = adsk.fusion.DistanceExtentDefinition.create(adsk.core.ValueInput.createByReal(0.0))



































































































        if l1Zpd1h3.profiles.count > 0:



































































































            if not wS1Cdn33 or SqnQ5RH5:



































































































                Q2n2R33J = fDD1v5nR.constructionPlanes



































































































                KbZcW4N4 = Q2n2R33J.createInput()



































































































                L76t2kFc = adsk.core.ValueInput.createByReal(0.0)



































































































                KbZcW4N4.setByOffset(hSzzCCB7, L76t2kFc)



































































































                ZQ3flgW6 = Q2n2R33J.add(KbZcW4N4)



































































































                if not wS1Cdn33:



































































































                    ZQ3flgW6.name = 'MT Plane'



































































































                kfZkzFC6 = fDD1v5nR.sketches



































































































                c9vf73l6 = kfZkzFC6.add(ZQ3flgW6)



































































































                c9vf73l6.name = 'MT Mortise'



































































































                c9vf73l6.isLightBulbOn = False



































































































                KVdcW1nN = nT6w4946(hmgtw4hP.faces.item(0)).body



































































































                BZmMLj26 = cs2VrBgr(c9vf73l6,



































































































                                                               cNn3G3L1,



































































































                                                               KVdcW1nN,



































































































                                                               not wS1Cdn33 and GShWQJjZ)



































































































                BZmMLj26.kkLqGPkv(pj43FN6D,



































































































                                                          V1D1W15N,



































































































                                                          cjLL1mfC,



































































































                                                          rw4bCR2q,



































































































                                                          HrFsPC41,



































































































                                                          RtRfj2k4,



































































































                                                          Bqsdh1L6,



































































































                                                          HRcH2TBZ,



































































































                                                          c9m8FFcz,



































































































                                                          nmMZj4nq,



































































































                                                          TKD8gGM4,



































































































                                                          chGf2pt1,



































































































                                                          Tmmj4MkK,



































































































                                                          tG9894DT)



































































































                b3wwkTW3 = adsk.core.ObjectCollection.create()



































































































                jb5fb9sj = c9vf73l6.profiles.item(0)



































































































                Plnz1474 = fDD1v5nR.features.extrudeFeatures



































































































                if kws7kMP6.count <= 1:



































































































                    Hh5F24L4 = Plnz1474.createInput(jb5fb9sj, adsk.fusion.FeatureOperations.CutFeatureOperation)  



































































































                    Hh5F24L4.participantBodies = [hmgtw4hP]



































































































                    Hh5F24L4.setTwoSidesExtent(s73sz8jv, Fh6pZLj2, jk46Pfrg, jk46Pfrg)



































































































                    Z463373z = Plnz1474.add(Hh5F24L4)



































































































                    if not wS1Cdn33:



































































































                        Z463373z.name = 'MT Extrude'



































































































                    b3wwkTW3.add(Z463373z)



































































































                else:



































































































                    QskWcM37 = fDD1v5nR.features.patchFeatures



































































































                    Sdn1dgqB = QskWcM37.createInput(jb5fb9sj, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)  



































































































                    gFKJ98tR = QskWcM37.add(Sdn1dgqB)



































































































                    if not wS1Cdn33:



































































































                        gFKJ98tR.name = 'MT Surface Patch'



































































































                    S3J232Th = gFKJ98tR.bodies.item(0)



































































































                    fhhbH25T = []



































































































                    fhhbH25T.append(S3J232Th)



































































































                    GCb7qSVm = lKGv9Qfm.features.copyPasteBodies.add(S3J232Th)



































































































                    if not wS1Cdn33:



































































































                        GCb7qSVm.name = 'MT Copy Paste Bodies'



































































































                    HvG3kLZ8 = GCb7qSVm.bodies.item(0)



































































































                    z5sJ4w5t = []



































































































                    for qPf1Nk77, F5GCMH6Q in enumerate(kws7kMP6):



































































































                        if qPf1Nk77 != 0:



































































































                            L67jR3gZ = HvG3kLZ8.createForAssemblyContext(F5GCMH6Q)



































































































                            z5sJ4w5t.append(L67jR3gZ)



































































































                    fhhbH25T.extend(z5sJ4w5t)



































































































                    Wl3Z7Tvm = []



































































































                    for td1Q1pn9 in fhhbH25T:



































































































                        Wl3Z7Tvm.append(td1Q1pn9.faces.item(0))



































































































                    RrL6sw3J = False



































































































                    for k7d2CmF7 in Wl3Z7Tvm:



































































































                        mV5Zmkcs = None



































































































                        j2fGpbvB = Plnz1474.count



































































































                        j73p9329 = False



































































































                        try:



































































































                            if not RrL6sw3J:



































































































                                Hh5F24L4 = Plnz1474.createInput(k7d2CmF7, adsk.fusion.FeatureOperations.CutFeatureOperation)  



































































































                                Hh5F24L4.participantBodies = [hmgtw4hP]



































































































                                Hh5F24L4.setTwoSidesExtent(s73sz8jv, Fh6pZLj2, jk46Pfrg, jk46Pfrg)



































































































                                Z463373z = Plnz1474.add(Hh5F24L4)



































































































                                if not wS1Cdn33:



































































































                                    Z463373z.name = 'MT Extrude'



































































































                                if Z463373z.healthState == adsk.fusion.FeatureHealthStates.WarningFeatureHealthState:



































































































                                    try:



































































































                                        cW4FwqvV = Plnz1474.count



































































































                                    except Exception:



































































































                                        return



































































































                                    if j2fGpbvB != cW4FwqvV:



































































































                                        Plnz1474.item(Plnz1474.count - 1).deleteMe()



































































































                                        j73p9329 = True



































































































                                    if not wS1Cdn33:



































































































                                        if not Cj6vGpgw:



































































































                                            p169ZFkB.messageBox('Unable to cut all mortises.', "Mortise and Tenon")



































































































                                            Cj6vGpgw = True



































































































                            else:



































































































                                raise ValueError



































































































                        except Exception:



































































































                            RrL6sw3J = True



































































































                            try:



































































































                                cW4FwqvV = Plnz1474.count



































































































                            except Exception:



































































































                                return



































































































                            if j2fGpbvB != cW4FwqvV:



































































































                                Plnz1474.item(Plnz1474.count - 1).deleteMe()



































































































                            mV5Zmkcs = kfZkzFC6.add(k7d2CmF7)



































































































                            if not wS1Cdn33:



































































































                                mV5Zmkcs.name = 'MT Mortise'



































































































                            PWfdWGp6 = mV5Zmkcs.profiles.item(0)



































































































                            Hh5F24L4 = Plnz1474.createInput(PWfdWGp6, adsk.fusion.FeatureOperations.CutFeatureOperation)  



































































































                            Hh5F24L4.participantBodies = [hmgtw4hP]



































































































                            Hh5F24L4.setTwoSidesExtent(s73sz8jv, Fh6pZLj2, jk46Pfrg, jk46Pfrg)



































































































                            Z463373z = Plnz1474.add(Hh5F24L4)



































































































                            if not wS1Cdn33:



































































































                                Z463373z.name = 'MT Extrude'



































































































                        if not j73p9329:



































































































                            b3wwkTW3.add(Z463373z)



































































































                        if mV5Zmkcs:



































































































                            mV5Zmkcs.isVisible = False



































































































                    if not wS1Cdn33:



































































































                        q6Gr4nwg = fDD1v5nR.features.removeFeatures



































































































                        P1lCfwqJ = q6Gr4nwg.add(S3J232Th)



































































































                        P1lCfwqJ.name = 'MT Remove Body'



































































































                        hMM86vvR = lKGv9Qfm.features.removeFeatures



































































































                        bpSmrV91 = hMM86vvR.add(HvG3kLZ8)



































































































                        bpSmrV91.name = 'MT Remove Body'



































































































                    else:



































































































                        S3J232Th.isVisible = False



































































































                        HvG3kLZ8.isVisible = False



































































































            VfBmQNGM = l1Zpd1h3.profiles.item(0)



































































































            jZ9hNCkw = n4vcQHR7.features.extrudeFeatures



































































































            if not wS1Cdn33 or SqnQ5RH5:



































































































                KCkh1rKJ = jZ9hNCkw.createInput(VfBmQNGM, adsk.fusion.FeatureOperations.JoinFeatureOperation)  



































































































                KCkh1rKJ.participantBodies = [hSzzCCB7.body]



































































































            else:



































































































                KCkh1rKJ = jZ9hNCkw.createInput(VfBmQNGM, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)  



































































































            KCkh1rKJ.setTwoSidesExtent(nS45KT97, Fh6pZLj2, jk46Pfrg, jk46Pfrg)



































































































            CD77rTjj = jZ9hNCkw.add(KCkh1rKJ)



































































































            if not wS1Cdn33:



































































































                CD77rTjj.name = 'MT Extrude'



































































































            if not wS1Cdn33 or SqnQ5RH5:



































































































                if T37BP79l > 0 or P6ns3lS7 > 0:



































































































                    C126fZFJ = vzpWG4J8.worldGeometry.asInfiniteLine().direction



































































































                if T37BP79l > 0:



































































































                    Hs2lwNmM = CD77rTjj.endFaces



































































































                    mPH7JSM7 = 0



































































































                    for qPf1Nk77, R7w91nHZ in enumerate(Hs2lwNmM):



































































































                        if R7w91nHZ.geometry.isParallelToPlane(KhMgctKR.geometry):  



































































































                            mPH7JSM7 = qPf1Nk77



































































































                    GMLRMh1p = Hs2lwNmM.item(mPH7JSM7)



































































































                    l8Tc447t = GMLRMh1p.edges



































































































                    Gbw3mfCm = l8Tc447t.item(0)  



































































































                    mmp64BJt = l8Tc447t.item(2)  



































































































                    dnlz1CnR = l8Tc447t.item(1)  



































































































                    V41qfGBz = l8Tc447t.item(3)  



































































































                    L1S3hwWN = Gbw3mfCm.geometry.asInfiniteLine().direction  



































































































                    g7h9sld1 = mmp64BJt.geometry.asInfiniteLine().direction  



































































































                    if L1S3hwWN.isParallelTo(C126fZFJ) or g7h9sld1.isParallelTo(C126fZFJ):



































































































                        BnjHkQrB = dnlz1CnR



































































































                        jQkFz5S2 = V41qfGBz



































































































                    else:



































































































                        BnjHkQrB = Gbw3mfCm



































































































                        jQkFz5S2 = mmp64BJt



































































































                    vRrg5WhC = n4vcQHR7.features.filletFeatures



































































































                    Q2CzMJ2F = adsk.core.ObjectCollection.create()



































































































                    Q2CzMJ2F.add(BnjHkQrB)



































































































                    Q2CzMJ2F.add(jQkFz5S2)



































































































                    l1t77C9d = adsk.core.ValueInput.createByString(SV2fMr1T)



































































































                    W1tFdRTj = vRrg5WhC.createInput()



































































































                    W1tFdRTj.edgeSetInputs.addConstantRadiusEdgeSet(Q2CzMJ2F, l1t77C9d, False)



































































































                    W1tFdRTj.isRollingBallCorner = True



































































































                    bK1VLDR3 = vRrg5WhC.add(W1tFdRTj)



































































































                    if not wS1Cdn33:



































































































                        bK1VLDR3.name = 'MT Fillet'



































































































                    if hg4lQqsk:



































































































                        kBLr94Rb = cL62qdlC.measureManager



































































































                        for J7QqS1hn in b3wwkTW3:



































































































                            s5gF8Kn3 = J7QqS1hn.sideFaces  



































































































                            mcFR7bz1 = adsk.core.ObjectCollection.create()



































































































                            for n6D122jb in s5gF8Kn3:



































































































                                if n6D122jb.geometry.normal.isParallelTo(BZmMLj26.HVF4495d.worldGeometry.asInfiniteLine().direction):  



































































































                                    lD3G6V4m = []



































































































                                    for FJSPH4P4 in n6D122jb.edges:



































































































                                        if ZQ3flgW6.geometry.isParallelToLine(FJSPH4P4.geometry):  



































































































                                            lD3G6V4m.append(FJSPH4P4)



































































































                                    G3fbR1fg = min(lD3G6V4m, key=lambda e: kBLr94Rb.measureMinimumDistance(ZQ3flgW6.geometry, e.startVertex.geometry).value)



































































































                                    mcFR7bz1.add(G3fbR1fg)



































































































                            hVb8561F = vRrg5WhC.createInput()



































































































                            hVb8561F.edgeSetInputs.addConstantRadiusEdgeSet(mcFR7bz1, l1t77C9d, False)



































































































                            hVb8561F.isRollingBallCorner = True



































































































                            try:



































































































                                l1Nb4dbj = vRrg5WhC.add(hVb8561F)



































































































                                if not wS1Cdn33:



































































































                                    l1Nb4dbj.name = 'MT Fillet'



































































































                            except Exception:



































































































                                if not wS1Cdn33:



































































































                                    p169ZFkB.messageBox('Unable to fillet mortise outer corners.', "Mortise and Tenon")



































































































                if P6ns3lS7 > 0:



































































































                    kBLr94Rb = cL62qdlC.measureManager



































































































                    G5NTPtRS = CD77rTjj.sideFaces



































































































                    D8r3vbFC = adsk.core.ObjectCollection.create()



































































































                    for n6D122jb in G5NTPtRS:



































































































                        if n6D122jb.geometry.normal.isParallelTo(C126fZFJ):  



































































































                            if SN46rVt5:



































































































                                print("pf")



































































































                            for FJSPH4P4 in n6D122jb.edges:



































































































                                if KhMgctKR.geometry.isParallelToLine(FJSPH4P4.geometry):  



































































































                                    if SN46rVt5:



































































































                                        print("pe")



































































































                                        print(kBLr94Rb.measureMinimumDistance(KhMgctKR.geometry, FJSPH4P4.startVertex.geometry).value)



































































































                                    if kBLr94Rb.measureMinimumDistance(KhMgctKR.geometry, FJSPH4P4.startVertex.geometry).value < 0.000000001:



































































































                                        D8r3vbFC.add(FJSPH4P4)



































































































                                        break



































































































                    vRrg5WhC = n4vcQHR7.features.filletFeatures



































































































                    Jt54t3mt = adsk.core.ValueInput.createByString(tb51gqV4)



































































































                    W1tFdRTj = vRrg5WhC.createInput()



































































































                    W1tFdRTj.edgeSetInputs.addConstantRadiusEdgeSet(D8r3vbFC, Jt54t3mt, False)



































































































                    W1tFdRTj.isRollingBallCorner = True



































































































                    try:



































































































                        ZZmcnsR2 = vRrg5WhC.add(W1tFdRTj)



































































































                        if not wS1Cdn33:



































































































                            ZZmcnsR2.name = 'MT Fillet'



































































































                    except Exception:



































































































                        if not wS1Cdn33:



































































































                            p169ZFkB.messageBox('Unable to fillet tenon inner corners.', "Mortise and Tenon")



































































































                    if b3wwkTW3.count != 0:



































































































                        v4HV97Dw = adsk.core.ObjectCollection.create()



































































































                        for J7QqS1hn in b3wwkTW3:



































































































                            if J7QqS1hn.endFaces.count > 0:  



































































































                                V85T4vGZ = J7QqS1hn.endFaces.item(0)  



































































































                                for FJSPH4P4 in V85T4vGZ.edges:



































































































                                    if BZmMLj26.HVF4495d.worldGeometry.asInfiniteLine().direction.isPerpendicularTo(FJSPH4P4.geometry.asInfiniteLine().direction):  



































































































                                        v4HV97Dw.add(FJSPH4P4)



































































































                        if v4HV97Dw.count > 0:



































































































                            pkJ2ZcMw = fDD1v5nR.features.filletFeatures



































































































                            H27D7qZ2 = pkJ2ZcMw.createInput()



































































































                            H27D7qZ2.edgeSetInputs.addConstantRadiusEdgeSet(v4HV97Dw, Jt54t3mt, False)



































































































                            H27D7qZ2.isRollingBallCorner = True



































































































                            try:



































































































                                ScPTnQ19 = pkJ2ZcMw.add(H27D7qZ2)



































































































                                if not wS1Cdn33:



































































































                                    ScPTnQ19.name = 'MT Fillet'



































































































                            except Exception:



































































































                                if not wS1Cdn33:



































































































                                    p169ZFkB.messageBox('Unable to fillet mortise inner corners.', "Mortise and Tenon")



































































































            if not wS1Cdn33 or SqnQ5RH5:



































































































                if Tft31kG6:



































































































                    if G43PQK2z != 0:



































































































                        g5B4CQz5 = CD77rTjj.sideFaces



































































































                        SN9v8GHR = []



































































































                        for R7w91nHZ in g5B4CQz5:



































































































                            if R7w91nHZ.geometry.isPerpendicularToLine(vzpWG4J8.worldGeometry):  



































































































                                SN9v8GHR.append(R7w91nHZ)



































































































                        if len(SN9v8GHR) != 0:



































































































                            BJk8D3M7 = n4vcQHR7.features.draftFeatures



































































































                            s3QF6cr5 = BJk8D3M7.createInput(SN9v8GHR, KhMgctKR, False)



































































































                            kFT229VD = adsk.core.ValueInput.createByString(s5SW75K2)



































































































                            s3QF6cr5.setSingleAngle(False, kFT229VD)



































































































                            s3QF6cr5.isDirectionFlipped = True



































































































                            try:



































































































                                BgQ76NNB = BJk8D3M7.add(s3QF6cr5)



































































































                                if not wS1Cdn33:



































































































                                    BgQ76NNB.name = 'MT Draft'



































































































                            except Exception:



































































































                                if not wS1Cdn33:



































































































                                    p169ZFkB.messageBox("Unable to create dovetails.", "Mortise and Tenon")



































































































                        if b3wwkTW3.count != 0:



































































































                            HrpWs56v = []



































































































                            for J7QqS1hn in b3wwkTW3:



































































































                                g5B4CQz5 = J7QqS1hn.sideFaces  



































































































                                jfTQCLHs = []



































































































                                for R7w91nHZ in g5B4CQz5:



































































































                                    if R7w91nHZ.geometry.isPerpendicularToLine(BZmMLj26.HVF4495d.worldGeometry):  



































































































                                        jfTQCLHs.append(R7w91nHZ)



































































































                                if len(jfTQCLHs) != 0:



































































































                                    F9q15FC6 = fDD1v5nR.features.draftFeatures



































































































                                    s3QF6cr5 = F9q15FC6.createInput(jfTQCLHs, ZQ3flgW6, False)



































































































                                    kFT229VD = adsk.core.ValueInput.createByString(s5SW75K2)



































































































                                    s3QF6cr5.setSingleAngle(False, kFT229VD)



































































































                                    s3QF6cr5.isDirectionFlipped = False



































































































                                    try:



































































































                                        kZFsZSFq = F9q15FC6.add(s3QF6cr5)



































































































                                        if not wS1Cdn33:



































































































                                            kZFsZSFq.name = 'MT Draft'



































































































                                        HrpWs56v.append(kZFsZSFq)



































































































                                    except Exception:



































































































                                        if not wS1Cdn33:



































































































                                            if not Cj6vGpgw:



































































































                                                p169ZFkB.messageBox('Unable to cut all mortises.', "Mortise and Tenon")



































































































                                                Cj6vGpgw = True



































































































                            for kZFsZSFq in HrpWs56v:



































































































                                b3wwkTW3.add(kZFsZSFq)  



































































































            if tPBR4wK3 > 1:



































































































                if not wS1Cdn33 and GShWQJjZ:



































































































                    if K5b17rzw:



































































































                        tgQqs3RZ = f'({S5B59jrP.name} - 2 * ({HrFsPC41}) - ({cjLL1mfC})) / ({wV47VGgp} - 1)'



































































































                    else:



































































































                        tgQqs3RZ = f'({S5B59jrP.name} - ({HrFsPC41}) - ({nGMd4MTf}) - ({cjLL1mfC})) / ({wV47VGgp} - 1)'



































































































                if not wS1Cdn33 or SqnQ5RH5:



































































































                    hC2Bbkrd = Fnljrl6Z(m66P7lZB(BZmMLj26.QfDfsz9b.worldGeometry.startPoint, BZmMLj26.QfDfsz9b.worldGeometry.endPoint), KVdcW1nN)  



































































































                    nT62lRsG = Fnljrl6Z(BZmMLj26.WnCkh2Rs, KVdcW1nN)  



































































































                    T8Gj6W1p = hC2Bbkrd.vectorTo(nT62lRsG)



































































































                    if SN46rVt5 and LwkC7J6M >= 3:



































































































                        library.createCustomGraphicsPoint(qzLPt3WM, hC2Bbkrd, "lcmp")



































































































                        library.createCustomGraphicsPoint(qzLPt3WM, nT62lRsG, "dpcr")



































































































                v1pr99tk = m66P7lZB(p8WGG6wf.worldGeometry.startPoint, p8WGG6wf.worldGeometry.endPoint)



































































































                c6m56Nzn = l1Zpd1h3.sketchToModelSpace(Jl17LcHz)



































































































                if SN46rVt5 and LwkC7J6M >= 3:



































































































                    library.createCustomGraphicsPoint(lKGv9Qfm, v1pr99tk, "lmp")



































































































                    library.createCustomGraphicsPoint(lKGv9Qfm, c6m56Nzn, "dpr")



































































































                zg3F7g51 = v1pr99tk.vectorTo(c6m56Nzn)



































































































                if not wS1Cdn33 and GShWQJjZ:



































































































                    HvQZ4tzn = adsk.core.ValueInput.createByString(wV47VGgp)



































































































                else:



































































































                    HvQZ4tzn = adsk.core.ValueInput.createByReal(tPBR4wK3)



































































































                LMjFdrbs = adsk.core.ValueInput.createByReal(1.0)



































































































                qJNsNsM6 = adsk.core.ObjectCollection.create()



































































































                qJNsNsM6.add(CD77rTjj)



































































































                if bK1VLDR3 is not None:



































































































                    qJNsNsM6.add(bK1VLDR3)



































































































                if ZZmcnsR2 is not None:



































































































                    qJNsNsM6.add(ZZmcnsR2)



































































































                if BgQ76NNB is not None:



































































































                    qJNsNsM6.add(BgQ76NNB)



































































































                qm4Nc1h9 = 1



































































































                fm27r43R = ''



































































































                TB12M1DF = vzpWG4J8.worldGeometry.asInfiniteLine().direction



































































































                if math.degrees(TB12M1DF.angleTo(zg3F7g51)) > 90:



































































































                    qm4Nc1h9 = -1



































































































                    fm27r43R = '-'



































































































                if SN46rVt5 and LwkC7J6M >= 3:



































































































                    library.createCustomGraphicsPoint(lKGv9Qfm, TB12M1DF.asPoint(), "dt")



































































































                    library.createCustomGraphicsPoint(lKGv9Qfm, zg3F7g51.asPoint(), "tcv")



































































































                    print("ta: " + str(math.degrees(TB12M1DF.angleTo(zg3F7g51))))



































































































                if not wS1Cdn33 and GShWQJjZ:



































































































                    P6WFV2rK = adsk.core.ValueInput.createByString(f'{fm27r43R}({tgQqs3RZ})')



































































































                else:



































































































                    P6WFV2rK = adsk.core.ValueInput.createByReal(j7tvrGCM * qm4Nc1h9)



































































































                Kb2v8f7l = lKGv9Qfm.features.rectangularPatternFeatures



































































































                hGgSZ5g1 = Kb2v8f7l.createInput(qJNsNsM6, vzpWG4J8, HvQZ4tzn, P6WFV2rK, adsk.fusion.PatternDistanceType.SpacingPatternDistanceType)  



































































































                hGgSZ5g1.patternComputeOption = adsk.fusion.PatternComputeOptions.AdjustPatternCompute  



































































































                hGgSZ5g1.quantityTwo = LMjFdrbs



































































































                try:



































































































                    KkKQ1K4L = Kb2v8f7l.add(hGgSZ5g1)



































































































                    if not wS1Cdn33:



































































































                        KkKQ1K4L.name = 'MT R-Pattern'



































































































                    if not wS1Cdn33 and GShWQJjZ:



































































































                        KkKQ1K4L.name = 'TenonPattern'



































































































                except Exception:



































































































                    if not wS1Cdn33:



































































































                        p169ZFkB.messageBox('Unable to add tenons.', "Mortise and Tenon")



































































































                if not wS1Cdn33 or SqnQ5RH5:



































































































                    if ScPTnQ19 is not None:



































































































                        b3wwkTW3.add(ScPTnQ19)



































































































                    if l1Nb4dbj is not None:



































































































                        b3wwkTW3.add(l1Nb4dbj)



































































































                    kBj59f61 = 1



































































































                    ZFqrnjcP = ''



































































































                    dBmtCDcR = Fnljrl6Z(BZmMLj26.HVF4495d.worldGeometry.asInfiniteLine().direction, KVdcW1nN.faces.item(0))  



































































































                    if math.degrees(dBmtCDcR.angleTo(T8Gj6W1p)) > 90:



































































































                        kBj59f61 = -1



































































































                        ZFqrnjcP = '-'



































































































                    if SN46rVt5 and LwkC7J6M >= 3:



































































































                        library.createCustomGraphicsPoint(qzLPt3WM, dBmtCDcR.asPoint(), "dm")



































































































                        library.createCustomGraphicsPoint(qzLPt3WM, T8Gj6W1p.asPoint(), "mcv")



































































































                        print("ma: " + str(math.degrees(dBmtCDcR.angleTo(T8Gj6W1p))))



































































































                    if not wS1Cdn33 and GShWQJjZ:



































































































                        P426pHT1 = adsk.core.ValueInput.createByString(f'{ZFqrnjcP}({tgQqs3RZ})')



































































































                    else:



































































































                        P426pHT1 = adsk.core.ValueInput.createByReal(j7tvrGCM * kBj59f61)



































































































                    F57mswl2 = fDD1v5nR.features.rectangularPatternFeatures



































































































                    Ws34r2Sk = F57mswl2.createInput(b3wwkTW3, BZmMLj26.HVF4495d, HvQZ4tzn, P426pHT1, adsk.fusion.PatternDistanceType.SpacingPatternDistanceType)  



































































































                    Ws34r2Sk.patternComputeOption = adsk.fusion.PatternComputeOptions.AdjustPatternCompute  



































































































                    Ws34r2Sk.quantityTwo = LMjFdrbs



































































































                    try:



































































































                        C74Sptf2 = F57mswl2.add(Ws34r2Sk)



































































































                        if not wS1Cdn33:



































































































                            C74Sptf2.name = 'MT R-Pattern'



































































































                    except Exception:



































































































                        if not wS1Cdn33:



































































































                            if not Cj6vGpgw:



































































































                                p169ZFkB.messageBox('Unable to cut all mortises.', "Mortise and Tenon")



































































































                                Cj6vGpgw = True



































































































    except Exception:



































































































        qN9pKtLP()



































































































def DzS53zST(vSlT3761, dffRs2fq, R8MW5z33, pW8Tkn1k, TZMlggrS):



































































































    global cL62qdlC



































































































    SCCnSTpn = cL62qdlC.activeProduct  



































































































    kP5kGthF = SCCnSTpn.userParameters



































































































    K1GWQT7n = vSlT3761 + str(dffRs2fq) + R8MW5z33



































































































    J3kfwQDV = K1GWQT7n



































































































    if kP5kGthF.itemByName(J3kfwQDV) is not None:



































































































        J73QZSlS = 1



































































































        while J73QZSlS < 1000:



































































































            J3kfwQDV = K1GWQT7n + f'_{J73QZSlS}'



































































































            if kP5kGthF.itemByName(J3kfwQDV) is not None:



































































































                J73QZSlS += 1



































































































            else:



































































































                break



































































































    Pz4BzCHz = adsk.core.ValueInput.createByString(pW8Tkn1k)



































































































    ckkRggVn = kP5kGthF.add(J3kfwQDV, Pz4BzCHz, TZMlggrS, '')



































































































    return ckkRggVn



































































































def WCv2S9m9():



































































































    global cL62qdlC



































































































    try:



































































































        SCCnSTpn = cL62qdlC.activeProduct  



































































































        kP5kGthF = SCCnSTpn.userParameters



































































































        qB4S9m8t = []



































































































        FNtWKK5k = []



































































































        for S5B59jrP in kP5kGthF:



































































































            Ts474JDS = S5B59jrP.name



































































































            if Ts474JDS[:2] == 'MT' and 'Width' in Ts474JDS:



































































































                jM5zBc1z = S5B59jrP.attributes.itemByName('MortiseAndTenon', 'sketchLineEntityToken')



































































































                if jM5zBc1z:



































































































                    S931PF7v = jM5zBc1z.value



































































































                    SHBV416h = SCCnSTpn.findEntityByToken(S931PF7v)



































































































                    PdzM4624 = None



































































































                    if SHBV416h:



































































































                        PdzM4624 = SHBV416h[0]  



































































































                    else:



































































































                        if SCCnSTpn.designType == adsk.fusion.DesignTypes.ParametricDesignType:



































































































                            d9c44dQG = SCCnSTpn.timeline



































































































                            for pK3hwL9m in d9c44dQG.timelineGroups:



































































































                                if pK3hwL9m.isCollapsed:



































































































                                    pK3hwL9m.isCollapsed = False



































































































                                    qB4S9m8t.append(pK3hwL9m)



































































































                            WDV496MF = False



































































































                            if len(FNtWKK5k) == 0:



































































































                                for gZwvDmwh in d9c44dQG:



































































































                                    if WDV496MF:



































































































                                        break



































































































                                    FNtWKK5k.append(gZwvDmwh.name)



































































































                            for qPf1Nk77, j3mdqNDS in enumerate(FNtWKK5k):



































































































                                if WDV496MF:



































































































                                    break



































































































                                if j3mdqNDS[:12] == 'TenonPattern':



































































































                                    gZwvDmwh = d9c44dQG.item(qPf1Nk77)



































































































                                    if gZwvDmwh.entity.objectType == adsk.fusion.RectangularPatternFeature.classType():



































































































                                        wgJ26kdV = gZwvDmwh.entity.distanceOne.expression  



































































































                                        if Ts474JDS in wgJ26kdV:



































































































                                            J73QZSlS = qPf1Nk77 - 1



































































































                                            while J73QZSlS >= 0:



































































































                                                if WDV496MF:



































































































                                                    break



































































































                                                D8FlnV3b = FNtWKK5k[J73QZSlS]



































































































                                                if D8FlnV3b[:5] == 'Tenon':



































































































                                                    T7nnDSgK = d9c44dQG.item(J73QZSlS)



































































































                                                    if T7nnDSgK.entity.objectType == adsk.fusion.Sketch.classType():



































































































                                                        l1Zpd1h3 = T7nnDSgK.entity  



































































































                                                        QkN67N42 = l1Zpd1h3.sketchDimensions



































































































                                                        for stKQdJHS in QkN67N42:



































































































                                                            if WDV496MF:



































































































                                                                break



































































































                                                            if stKQdJHS.objectType == adsk.fusion.SketchLinearDimension.classType() and not stKQdJHS.isDriving:



































































































                                                                dNmLjL31 = stKQdJHS.entityOne  



































































































                                                                wg1Zrj6G = stKQdJHS.entityTwo  



































































































                                                                if dNmLjL31.objectType == adsk.fusion.SketchPoint.classType() and wg1Zrj6G.objectType == adsk.fusion.SketchPoint.classType():



































































































                                                                    P3vQfv9c = dNmLjL31.connectedEntities



































































































                                                                    for vfRwM461 in P3vQfv9c:



































































































                                                                        if vfRwM461.objectType == adsk.fusion.SketchLine.classType():



































































































                                                                            if vfRwM461.startSketchPoint == wg1Zrj6G or vfRwM461.endSketchPoint == wg1Zrj6G:



































































































                                                                                PdzM4624 = vfRwM461



































































































                                                                                S5B59jrP.attributes.add("MortiseAndTenon", 'sketchLineEntityToken', PdzM4624.entityToken)  



































































































                                                                                WDV496MF = True



































































































                                                                                break



































































































                                                J73QZSlS = J73QZSlS - 1



































































































                    if PdzM4624 is not None:



































































































                        S5B59jrP.expression = f'{PdzM4624.length * 10} mm'



































































































        for ThZsM7VG in qB4S9m8t:



































































































            ThZsM7VG.isCollapsed = True



































































































    except Exception:



































































































        qN9pKtLP()



































































































def Vhssm1gV():



































































































    global wq6D3162



































































































    try:



































































































        if p169ZFkB.palettes.itemById('mortiseAndTenonHelpPalette'):



































































































            p169ZFkB.palettes.itemById('mortiseAndTenonHelpPalette').deleteMe()



































































































            wq6D3162.clear()



































































































        Lm5MVNn6 = p169ZFkB.palettes.add('mortiseAndTenonHelpPalette', 'Mortise and Tenon Help', './Resources/Help/Help.html', True, True, True, 530, 630)



































































































        Lm5MVNn6.setPosition(5, 300)



































































































        if len(wq6D3162) == 0:



































































































            mp41sz25 = WGv9M3Pw()



































































































            Lm5MVNn6.incomingFromHTML.add(mp41sz25)



































































































            wq6D3162.append(mp41sz25)



































































































    except Exception:



































































































        qN9pKtLP()



































































































class BPdg8Hbp(adsk.core.CommandCreatedEventHandler):



































































































    def __init__(Q7B515Ph):



































































































        super().__init__()



































































































    def notify(Q7B515Ph, j7kLD7nV):



































































































        try:



































































































            global cL62qdlC



































































































            global p169ZFkB



































































































            global P6KQF3wm



































































































            global ZwNS2R4W



































































































            global p1wP7Jl7



































































































            global wq6D3162



































































































            global lMB54F3t



































































































            global kcPDHw12



































































































            global PdGGWvR1



































































































            global rcJ7r114



































































































            global kgmD6nNg



































































































            global B5jc69Kk



































































































            global CL93gkpW



































































































            global cH5Kn9lM



































































































            wq6D3162 = []



































































































            lMB54F3t = None



































































































            PdGGWvR1 = False



































































































            rcJ7r114 = False



































































































            CL93gkpW = False



































































































            kgmD6nNg = True



































































































            B5jc69Kk = j7kLD7nV.command



































































































            B5jc69Kk.isPositionDependent = True



































































































            SCCnSTpn = cL62qdlC.activeProduct  



































































































            if SCCnSTpn.designType != adsk.fusion.DesignTypes.ParametricDesignType:



































































































                FFLF3ffF = p169ZFkB.messageBox('<div align="left">Parametric design needs to be active to execute Mortise and Tenon. Would you like to change to the parametric design?', 'Mortise and Tenon', adsk.core.MessageBoxButtonTypes.YesNoCancelButtonType, adsk.core.MessageBoxIconTypes.QuestionIconType)  



































































































                if FFLF3ffF == adsk.core.DialogResults.DialogYes:



































































































                    SCCnSTpn.designType = adsk.fusion.DesignTypes.ParametricDesignType  



































































































                else:



































































































                    return None



































































































            cH5Kn9lM = SCCnSTpn.timeline.markerPosition



































































































            q5fbft8N = mqN834w4()



































































































            if q5fbft8N:



































































































                kcPDHw12 = q5fbft8N



































































































            z6Z9Cnn8 = SCCnSTpn.unitsManager.defaultLengthUnits



































































































            CV8r5rTR = False



































































































            qd7LfHBp = GKvgKwgK()



































































































            if qd7LfHBp:



































































































                if len(qd7LfHBp) == 28:



































































































                    CV8r5rTR = True



































































































            sv874cfs = j7kLD7nV.command



































































































            gm83dVfh = sv874cfs.commandInputs



































































































            P6KQF3wm = gm83dVfh



































































































            ZwNS2R4W = H44bB1GG()



































































































            ZwNS2R4W.Ghjt2RRG = gm83dVfh.addTabCommandInput('tabCreate', 'Create')



































































































            ZwNS2R4W.Sg5VkTCp = gm83dVfh.addTabCommandInput('tabUpdate', 'Update')



































































































            ZwNS2R4W.LWDFPN31 = gm83dVfh.addSelectionInput('selectionBoard', 'Board', 'Select board to cut')



































































































            ZwNS2R4W.LWDFPN31.setSelectionLimits(0, 1)



































































































            ZwNS2R4W.LWDFPN31.addSelectionFilter('SolidBodies')



































































































            ZwNS2R4W.LWDFPN31.tooltip = 'Select a board to cut the mortise.'



































































































            ZwNS2R4W.LWDFPN31.toolClipFilename = './Resources/Board.png'



































































































            ZwNS2R4W.ps3sJ5RT = gm83dVfh.addSelectionInput('selectionFace', 'Face', 'Select face')



































































































            ZwNS2R4W.ps3sJ5RT.setSelectionLimits(0, 1)



































































































            ZwNS2R4W.ps3sJ5RT.addSelectionFilter('PlanarFaces')



































































































            ZwNS2R4W.ps3sJ5RT.tooltip = 'Select a face for the tenon.'



































































































            ZwNS2R4W.ps3sJ5RT.toolClipFilename = './Resources/Face.png'



































































































            ZwNS2R4W.bF64vM4J = gm83dVfh.addValueInput('depth', 'Depth', z6Z9Cnn8, adsk.core.ValueInput.createByReal(2.08))



































































































            ZwNS2R4W.bF64vM4J.minimumValue = 0



































































































            ZwNS2R4W.bF64vM4J.isMinimumInclusive = False



































































































            ZwNS2R4W.bF64vM4J.toolClipFilename = './Resources/Parameters.png'



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.bF64vM4J.expression = qd7LfHBp[0]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.BNSmRj3w = gm83dVfh.addDistanceValueCommandInput('length', 'Length', adsk.core.ValueInput.createByReal(3.0))



































































































            ZwNS2R4W.BNSmRj3w.isEnabled = False



































































































            ZwNS2R4W.BNSmRj3w.minimumValue = 0



































































































            ZwNS2R4W.BNSmRj3w.isMinimumValueInclusive = False



































































































            ZwNS2R4W.BNSmRj3w.toolClipFilename = './Resources/Parameters.png'



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.BNSmRj3w.expression = qd7LfHBp[1]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.gLP8cVZ4 = gm83dVfh.addDistanceValueCommandInput('spacing', 'Spacing', adsk.core.ValueInput.createByReal(3.0))



































































































            ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































            ZwNS2R4W.gLP8cVZ4.minimumValue = 0



































































































            ZwNS2R4W.gLP8cVZ4.isMinimumValueInclusive = False



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.gLP8cVZ4.expression = qd7LfHBp[2]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.Lr79LGrP = gm83dVfh.addValueInput('numberOfTenons', 'Number of Tenons', '', adsk.core.ValueInput.createByString('1'))



































































































            ZwNS2R4W.Lr79LGrP.minimumValue = 1



































































































            ZwNS2R4W.Lr79LGrP.maximumValue = 300



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.Lr79LGrP.expression = qd7LfHBp[3]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.sSqJdGS2 = gm83dVfh.addDistanceValueCommandInput('offset1', 'Offset 1', adsk.core.ValueInput.createByString('0'))



































































































            ZwNS2R4W.sSqJdGS2.isEnabled = False



































































































            ZwNS2R4W.sSqJdGS2.minimumValue = 0



































































































            ZwNS2R4W.sSqJdGS2.toolClipFilename = './Resources/Parameters.png'



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.sSqJdGS2.expression = qd7LfHBp[4]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.QbrrQGbk = gm83dVfh.addDistanceValueCommandInput('offset2', 'Offset 2', adsk.core.ValueInput.createByString('0'))



































































































            ZwNS2R4W.QbrrQGbk.isEnabled = False



































































































            ZwNS2R4W.QbrrQGbk.minimumValue = 0



































































































            ZwNS2R4W.QbrrQGbk.toolClipFilename = './Resources/Parameters.png'



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.QbrrQGbk.expression = qd7LfHBp[5]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.J5JBSfmt = gm83dVfh.addBoolValueInput('centered', 'Centered', True, '', False)



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.J5JBSfmt.value = bool(qd7LfHBp[6])



































































































            ZwNS2R4W.gz64kP2J = gm83dVfh.addBoolValueInput('flip', 'Flip', True, '', False)



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.gz64kP2J.value = bool(qd7LfHBp[7])



































































































            ZwNS2R4W.PSdzp5B5 = gm83dVfh.addValueInput('fillet', 'Fillet Radius', z6Z9Cnn8, adsk.core.ValueInput.createByReal(0.5))



































































































            ZwNS2R4W.PSdzp5B5.minimumValue = 0



































































































            ZwNS2R4W.PSdzp5B5.maximumValue = ZwNS2R4W.bF64vM4J.value



































































































            ZwNS2R4W.PSdzp5B5.isMaximumInclusive = True



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.PSdzp5B5.expression = qd7LfHBp[8]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.LL9wQm1D = gm83dVfh.addValueInput('innerFillet', 'Inner Fillet Radius', z6Z9Cnn8, adsk.core.ValueInput.createByReal(0.5))



































































































            ZwNS2R4W.LL9wQm1D.minimumValue = 0



































































































            ZwNS2R4W.LL9wQm1D.maximumValue = ZwNS2R4W.bF64vM4J.value



































































































            ZwNS2R4W.LL9wQm1D.isMaximumInclusive = True



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.LL9wQm1D.expression = qd7LfHBp[9]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.h3kD3bPH = gm83dVfh.addValueInput('lengthOffset', 'Length Offset', z6Z9Cnn8, adsk.core.ValueInput.createByReal(0.02))



































































































            ZwNS2R4W.h3kD3bPH.toolClipFilename = './Resources/Parameters.png'



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.h3kD3bPH.expression = qd7LfHBp[10]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.Q1Wt9542 = gm83dVfh.addValueInput('thicknessOffset', 'Thickness Offset', z6Z9Cnn8, adsk.core.ValueInput.createByReal(0.02))



































































































            ZwNS2R4W.Q1Wt9542.minimumValue = 0



































































































            ZwNS2R4W.Q1Wt9542.toolClipFilename = './Resources/Parameters.png'



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.Q1Wt9542.expression = qd7LfHBp[11]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.dk8l23Jk = gm83dVfh.addValueInput('depthOffsetValue', 'Depth Offset', z6Z9Cnn8, adsk.core.ValueInput.createByReal(0.0))



































































































            ZwNS2R4W.dk8l23Jk.minimumValue = 0



































































































            ZwNS2R4W.dk8l23Jk.toolClipFilename = './Resources/Parameters.png'



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.dk8l23Jk.expression = qd7LfHBp[12]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.JD2d2QCJ = gm83dVfh.addValueInput('tenonOffset1', 'Tenon Offset 1', z6Z9Cnn8, adsk.core.ValueInput.createByReal(0.0))



































































































            ZwNS2R4W.JD2d2QCJ.minimumValue = 0



































































































            ZwNS2R4W.JD2d2QCJ.toolClipFilename = './Resources/Parameters.png'



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.JD2d2QCJ.expression = qd7LfHBp[13]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.cpvnhgc7 = gm83dVfh.addValueInput('tenonOffset2', 'Tenon Offset 2', z6Z9Cnn8, adsk.core.ValueInput.createByReal(0.0))



































































































            ZwNS2R4W.cpvnhgc7.minimumValue = 0



































































































            ZwNS2R4W.cpvnhgc7.toolClipFilename = './Resources/Parameters.png'



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.cpvnhgc7.expression = qd7LfHBp[14]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.JLPzwfKJ = gm83dVfh.addBoolValueInput('flipTenonOffset', 'Flip Tenon Offset', True, '', False)



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.JLPzwfKJ.value = bool(qd7LfHBp[15])



































































































            ZwNS2R4W.W5GjH93c = gm83dVfh.addValueInput('dovetailAngle', 'Dovetail Angle', 'deg', adsk.core.ValueInput.createByString('15 deg'))



































































































            ZwNS2R4W.W5GjH93c.minimumValue = math.radians(-90)



































































































            ZwNS2R4W.W5GjH93c.isMinimumInclusive = False



































































































            ZwNS2R4W.W5GjH93c.maximumValue = math.radians(90)



































































































            ZwNS2R4W.W5GjH93c.isMaximumInclusive = False



































































































            if CV8r5rTR:



































































































                try:



































































































                    ZwNS2R4W.W5GjH93c.expression = qd7LfHBp[16]



































































































                except Exception:



































































































                    pass



































































































            ZwNS2R4W.f7Md1glS = gm83dVfh.addBoolValueInput('preview', 'Preview', True, '', True)



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.f7Md1glS.value = bool(qd7LfHBp[17])



































































































            ZwNS2R4W.Fsjlw27N = gm83dVfh.addBoolValueInput('computeSpacing', 'Update Spacing', False, '', False)



































































































            ZwNS2R4W.Fsjlw27N.resourceFolder = './Resources/Compute'



































































































            ZwNS2R4W.Fsjlw27N.tooltip = 'Updates the spacing of existing tenons created with the checked Constrained checkbox to follow the changes of the board width.'



































































































            ZwNS2R4W.Fsjlw27N.isVisible = False



































































































            ZwNS2R4W.S5PV6c1T = gm83dVfh.addBoolValueInput('helpButton', 'Help', False, './Resources/Help', False)



































































































            if kcPDHw12 is False:



































































































                gm83dVfh.addTextBoxCommandInput('readonlyTextBox', '', '<div align="left">The trial is limited to a preview. You can buy a license at <a href="https://maciejrogowski.com/">maciejrogowski.com</a></div>', 3, True)



































































































                lMcgK1b4 = gm83dVfh.addTextBoxCommandInput('validKeyTextBox', '', 'The license key is valid.', 3, True)



































































































                lMcgK1b4.isVisible = False



































































































                s5BHNSp5 = gm83dVfh.addStringValueInput('key', 'License Key', '')



































































































                s5BHNSp5.tooltip = "Forgot your license key? Contact us at info@maciejrogowski.com. We are here to help you."



































































































            ZwNS2R4W.tmZbm648 = gm83dVfh.addGroupCommandInput('settingsGroup', 'Settings')



































































































            ZwNS2R4W.tmZbm648.isExpanded = False



































































































            ZwNS2R4W.tmZbm648.isEnabledCheckBoxDisplayed = False



































































































            npP7hCg4 = ZwNS2R4W.tmZbm648.children



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.tmZbm648.isExpanded = bool(qd7LfHBp[18])



































































































            ZwNS2R4W.wGmH5CNj = npP7hCg4.addBoolValueInput('constrained', 'Constrained', True, '', True)



































































































            ZwNS2R4W.wGmH5CNj.tooltip = 'Creates constrained geometry. Adds inputs to the parameter table. The constrained geometry \ncalculates longer, but it better follows the changes in the board and face dimensions.'



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.wGmH5CNj.value = bool(qd7LfHBp[19])



































































































            ZwNS2R4W.b3v5Ssk4 = npP7hCg4.addBoolValueInput('depthOffset', 'Depth Offset', True, '', False)



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.b3v5Ssk4.value = bool(qd7LfHBp[20])



































































































            if ZwNS2R4W.b3v5Ssk4.value is False:



































































































                ZwNS2R4W.dk8l23Jk.isVisible = False



































































































                ZwNS2R4W.dk8l23Jk.isEnabled = False



































































































            ZwNS2R4W.bV3M5dz6 = npP7hCg4.addBoolValueInput('detailedPreview', 'Detailed Preview', True, '', True)



































































































            ZwNS2R4W.bV3M5dz6.tooltip = 'Preview with all details.'



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.bV3M5dz6.value = bool(qd7LfHBp[21])



































































































            ZwNS2R4W.V6vvQ6NG = npP7hCg4.addBoolValueInput('isDovetail', 'Dovetail', True, '', False)



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.V6vvQ6NG.value = bool(qd7LfHBp[22])



































































































            if ZwNS2R4W.V6vvQ6NG.value is False:



































































































                ZwNS2R4W.W5GjH93c.isVisible = False



































































































                ZwNS2R4W.W5GjH93c.isEnabled = False



































































































            ZwNS2R4W.jR29GP4P = npP7hCg4.addBoolValueInput('evenSpacing', 'Even', True, '', False)



































































































            ZwNS2R4W.jR29GP4P.tooltip = 'Even mortises and tenons.'



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.jR29GP4P.value = bool(qd7LfHBp[23])



































































































            ZwNS2R4W.tcB3Hj5T = npP7hCg4.addBoolValueInput('rotate', 'Rotate', True, '', False)



































































































            ZwNS2R4W.tcB3Hj5T.tooltip = 'Rotates mortises and tenons.'



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.tcB3Hj5T.value = bool(qd7LfHBp[24])



































































































            ZwNS2R4W.jQWPbQr7 = npP7hCg4.addBoolValueInput('roundCorners', 'Round Corners', True, '', False)



































































































            ZwNS2R4W.jQWPbQr7.tooltip = 'Rounds the inner corners.'



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.jQWPbQr7.value = bool(qd7LfHBp[25])



































































































            ZwNS2R4W.Vf7PTk49 = npP7hCg4.addBoolValueInput('tenonOffset', 'Tenon Offset', True, '', False)



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.Vf7PTk49.value = bool(qd7LfHBp[26])



































































































            ZwNS2R4W.JdLw9ZZr = npP7hCg4.addBoolValueInput('isSpacing', 'Spacing', True, '', False)



































































































            ZwNS2R4W.JdLw9ZZr.tooltip = 'Spacing between tenons.'



































































































            if CV8r5rTR:



































































































                ZwNS2R4W.JdLw9ZZr.value = bool(qd7LfHBp[27])



































































































            if ZwNS2R4W.JdLw9ZZr.value is False:



































































































                ZwNS2R4W.gLP8cVZ4.isVisible = False



































































































                ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































            if ZwNS2R4W.Vf7PTk49.value is False:



































































































                ZwNS2R4W.JD2d2QCJ.isVisible = False



































































































                ZwNS2R4W.JD2d2QCJ.isEnabled = False



































































































                ZwNS2R4W.cpvnhgc7.isVisible = False



































































































                ZwNS2R4W.cpvnhgc7.isEnabled = False



































































































                ZwNS2R4W.JLPzwfKJ.isVisible = False



































































































            if ZwNS2R4W.jQWPbQr7.value is False:



































































































                ZwNS2R4W.LL9wQm1D.isVisible = False



































































































                ZwNS2R4W.LL9wQm1D.isEnabled = False



































































































            PvmGG6GB = Jj52dk3c()



































































































            sv874cfs.preSelect.add(PvmGG6GB)



































































































            p1wP7Jl7.append(PvmGG6GB)



































































































            RJ2P6Cmd = RJHK6DfG()



































































































            sv874cfs.mouseDragBegin.add(RJ2P6Cmd)



































































































            p1wP7Jl7.append(RJ2P6Cmd)



































































































            Ghdb821W = nG255fSq()



































































































            sv874cfs.mouseDragEnd.add(Ghdb821W)



































































































            p1wP7Jl7.append(Ghdb821W)



































































































            ZqQQznHM = cHk88dw1()



































































































            sv874cfs.inputChanged.add(ZqQQznHM)



































































































            p1wP7Jl7.append(ZqQQznHM)



































































































            w1R33pGS = Fd5VHRJV()



































































































            sv874cfs.keyDown.add(w1R33pGS)



































































































            p1wP7Jl7.append(w1R33pGS)



































































































            V3JJ6b5n = tgSDS4Cz()



































































































            sv874cfs.validateInputs.add(V3JJ6b5n)



































































































            p1wP7Jl7.append(V3JJ6b5n)



































































































            z3K3V9sv = QB9cqm6r()



































































































            sv874cfs.executePreview.add(z3K3V9sv)



































































































            p1wP7Jl7.append(z3K3V9sv)



































































































            l8P1p8pd = phQ37n32()



































































































            sv874cfs.execute.add(l8P1p8pd)



































































































            p1wP7Jl7.append(l8P1p8pd)



































































































            WBTbM46k = pJS6qpL1()



































































































            sv874cfs.destroy.add(WBTbM46k)



































































































            p1wP7Jl7.append(WBTbM46k)



































































































        except Exception:



































































































            qN9pKtLP()



































































































class Jj52dk3c(adsk.core.SelectionEventHandler):



































































































    def __init__(Q7B515Ph):



































































































        super().__init__()



































































































    def notify(Q7B515Ph, gr2bWCKM):



































































































        try:



































































































            global cL62qdlC



































































































            nsv977v6 = gr2bWCKM.firingEvent.activeInput  



































































































            QnFvdcFP = gr2bWCKM.selection.entity



































































































            if nsv977v6.id == 'selectionFace':



































































































                hSzzCCB7 = gr2bWCKM.selection.entity  



































































































                m98pZmWH = False



































































































                for FJSPH4P4 in hSzzCCB7.edges:



































































































                    if FJSPH4P4.geometry.curveType == adsk.core.Curve3DTypes.Line3DCurveType:



































































































                        m98pZmWH = True



































































































                        break



































































































                if not m98pZmWH:



































































































                    gr2bWCKM.isSelectable = False



































































































                else:



































































































                    qHVMkJcl = True



































































































                    J4d7z9s6 = hSzzCCB7.edges



































































































                    lc7Ckl9K = list(filter(lambda FJSPH4P4: FJSPH4P4.geometry.curveType == adsk.core.Curve3DTypes.Line3DCurveType, J4d7z9s6))



































































































                    sfq44Fcm = max(lc7Ckl9K, key=lambda FJSPH4P4: FJSPH4P4.length)



































































































                    kBLr94Rb = cL62qdlC.measureManager



































































































                    v2KjNnQ3 = hSzzCCB7.vertices



































































































                    for p5B5426F in v2KjNnQ3:



































































































                        L71NVqs2 = kBLr94Rb.measureMinimumDistance(p5B5426F, sfq44Fcm).value



































































































                        if L71NVqs2 > 0:



































































































                            qHVMkJcl = False



































































































                            break



































































































                    if qHVMkJcl:



































































































                        gr2bWCKM.isSelectable = False



































































































            if nsv977v6.id == "selectionBoard" or nsv977v6.id == 'selectionFace':



































































































                if F6Dn2jTn(QnFvdcFP):



































































































                    gr2bWCKM.isSelectable = False



































































































        except Exception:



































































































            qN9pKtLP()



































































































class RJHK6DfG(adsk.core.MouseEventHandler):



































































































    def __init__(Q7B515Ph):



































































































        super().__init__()



































































































    def notify(Q7B515Ph, gr2bWCKM):



































































































        try:



































































































            global PdGGWvR1



































































































            if gr2bWCKM.button == adsk.core.MouseButtons.LeftMouseButton:



































































































                PdGGWvR1 = True



































































































            else:



































































































                PdGGWvR1 = False



































































































        except Exception:



































































































            qN9pKtLP()



































































































class nG255fSq(adsk.core.MouseEventHandler):



































































































    def __init__(Q7B515Ph):



































































































        super().__init__()



































































































    def notify(Q7B515Ph, j7kLD7nV):



































































































        try:



































































































            global B5jc69Kk



































































































            global ZwNS2R4W



































































































            global PdGGWvR1



































































































            global rcJ7r114



































































































            PdGGWvR1 = False



































































































            if ZwNS2R4W.bV3M5dz6.value and rcJ7r114:



































































































                try:



































































































                    B5jc69Kk.doExecutePreview()  



































































































                except Exception:



































































































                    pass



































































































                rcJ7r114 = False



































































































        except Exception:



































































































            qN9pKtLP()



































































































class cHk88dw1(adsk.core.InputChangedEventHandler):



































































































    def __init__(Q7B515Ph):



































































































        super().__init__()



































































































    def notify(Q7B515Ph, gr2bWCKM):



































































































        try:



































































































            gm83dVfh = gr2bWCKM.inputs



































































































            HVLm722j = gr2bWCKM.input.id



































































































            global lMB54F3t



































































































            global kcPDHw12



































































































            global rcJ7r114



































































































            global CL93gkpW



































































































            global ZwNS2R4W



































































































            global hFbJcsRM



































































































            global kgmD6nNg



































































































            global gp2rCsr4



































































































            global cH5Kn9lM



































































































            if ZwNS2R4W.LWDFPN31:



































































































                if HVLm722j == "APITabBar" and not kgmD6nNg and gm83dVfh.itemById('tabCreate'):



































































































                    if ZwNS2R4W.Ghjt2RRG.isActive:



































































































                        kgmD6nNg = True



































































































                        ZwNS2R4W.Fsjlw27N.isVisible = False



































































































                        ZwNS2R4W.LWDFPN31.isVisible = True



































































































                        ZwNS2R4W.ps3sJ5RT.isVisible = True



































































































                        ZwNS2R4W.bF64vM4J.isVisible = True



































































































                        ZwNS2R4W.bF64vM4J.isEnabled = True



































































































                        ZwNS2R4W.BNSmRj3w.isVisible = True



































































































                        ZwNS2R4W.gLP8cVZ4.isVisible = ZwNS2R4W.hFm22fDd



































































































                        ZwNS2R4W.gLP8cVZ4.isEnabled = ZwNS2R4W.hFm22fDd



































































































                        ZwNS2R4W.Lr79LGrP.isVisible = True



































































































                        ZwNS2R4W.Lr79LGrP.isEnabled = True



































































































                        ZwNS2R4W.sSqJdGS2.isVisible = True



































































































                        ZwNS2R4W.QbrrQGbk.isVisible = True



































































































                        ZwNS2R4W.J5JBSfmt.isVisible = True



































































































                        ZwNS2R4W.gz64kP2J.isVisible = True



































































































                        ZwNS2R4W.PSdzp5B5.isVisible = True



































































































                        ZwNS2R4W.PSdzp5B5.isEnabled = True



































































































                        ZwNS2R4W.LL9wQm1D.isVisible = ZwNS2R4W.GTKz6Dn1



































































































                        ZwNS2R4W.LL9wQm1D.isEnabled = ZwNS2R4W.GTKz6Dn1



































































































                        ZwNS2R4W.h3kD3bPH.isVisible = True



































































































                        ZwNS2R4W.h3kD3bPH.isEnabled = True



































































































                        ZwNS2R4W.Q1Wt9542.isVisible = True



































































































                        ZwNS2R4W.Q1Wt9542.isEnabled = True



































































































                        ZwNS2R4W.dk8l23Jk.isVisible = ZwNS2R4W.R486tm21



































































































                        ZwNS2R4W.dk8l23Jk.isEnabled = ZwNS2R4W.R486tm21



































































































                        ZwNS2R4W.JD2d2QCJ.isVisible = ZwNS2R4W.njdv6vjT



































































































                        ZwNS2R4W.JD2d2QCJ.isEnabled = ZwNS2R4W.njdv6vjT



































































































                        ZwNS2R4W.cpvnhgc7.isVisible = ZwNS2R4W.S68jJm9D



































































































                        ZwNS2R4W.cpvnhgc7.isEnabled = ZwNS2R4W.S68jJm9D



































































































                        ZwNS2R4W.W5GjH93c.isVisible = ZwNS2R4W.zs1STq6T



































































































                        ZwNS2R4W.W5GjH93c.isEnabled = ZwNS2R4W.zs1STq6T



































































































                        ZwNS2R4W.JLPzwfKJ.isVisible = ZwNS2R4W.g21k9PKG



































































































                        ZwNS2R4W.f7Md1glS.isVisible = True



































































































                        ZwNS2R4W.tmZbm648.isVisible = True



































































































                        if lMB54F3t is not None:



































































































                            lMB54F3t.isSelectable = True



































































































                if HVLm722j == "APITabBar" and kgmD6nNg and gm83dVfh.itemById('tabUpdate'):



































































































                    if ZwNS2R4W.Sg5VkTCp.isActive:



































































































                        kgmD6nNg = False



































































































                        ZwNS2R4W.LWDFPN31.clearSelection()



































































































                        ZwNS2R4W.ps3sJ5RT.clearSelection()



































































































                        ZwNS2R4W.Fsjlw27N.isVisible = True



































































































                        ZwNS2R4W.LWDFPN31.isVisible = False



































































































                        ZwNS2R4W.ps3sJ5RT.isVisible = False



































































































                        ZwNS2R4W.bF64vM4J.isVisible = False



































































































                        ZwNS2R4W.bF64vM4J.isEnabled = False



































































































                        ZwNS2R4W.BNSmRj3w.isVisible = False



































































































                        ZwNS2R4W.hFm22fDd = ZwNS2R4W.gLP8cVZ4.isVisible



































































































                        ZwNS2R4W.gLP8cVZ4.isVisible = False



































































































                        ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































                        ZwNS2R4W.Lr79LGrP.isVisible = False



































































































                        ZwNS2R4W.Lr79LGrP.isEnabled = False



































































































                        ZwNS2R4W.sSqJdGS2.isVisible = False



































































































                        ZwNS2R4W.QbrrQGbk.isVisible = False



































































































                        ZwNS2R4W.J5JBSfmt.isVisible = False



































































































                        ZwNS2R4W.gz64kP2J.isVisible = False



































































































                        ZwNS2R4W.PSdzp5B5.isVisible = False



































































































                        ZwNS2R4W.PSdzp5B5.isEnabled = False



































































































                        ZwNS2R4W.GTKz6Dn1 = ZwNS2R4W.LL9wQm1D.isVisible



































































































                        ZwNS2R4W.LL9wQm1D.isVisible = False



































































































                        ZwNS2R4W.LL9wQm1D.isEnabled = False



































































































                        ZwNS2R4W.h3kD3bPH.isVisible = False



































































































                        ZwNS2R4W.h3kD3bPH.isEnabled = False



































































































                        ZwNS2R4W.Q1Wt9542.isVisible = False



































































































                        ZwNS2R4W.Q1Wt9542.isEnabled = False



































































































                        ZwNS2R4W.R486tm21 = ZwNS2R4W.dk8l23Jk.isVisible



































































































                        ZwNS2R4W.dk8l23Jk.isVisible = False



































































































                        ZwNS2R4W.dk8l23Jk.isEnabled = False



































































































                        ZwNS2R4W.njdv6vjT = ZwNS2R4W.JD2d2QCJ.isVisible



































































































                        ZwNS2R4W.JD2d2QCJ.isVisible = False



































































































                        ZwNS2R4W.JD2d2QCJ.isEnabled = False



































































































                        ZwNS2R4W.S68jJm9D = ZwNS2R4W.cpvnhgc7.isVisible



































































































                        ZwNS2R4W.cpvnhgc7.isVisible = False



































































































                        ZwNS2R4W.cpvnhgc7.isEnabled = False



































































































                        ZwNS2R4W.zs1STq6T = ZwNS2R4W.W5GjH93c.isVisible



































































































                        ZwNS2R4W.W5GjH93c.isVisible = False



































































































                        ZwNS2R4W.W5GjH93c.isEnabled = False



































































































                        ZwNS2R4W.g21k9PKG = ZwNS2R4W.JLPzwfKJ.isVisible



































































































                        ZwNS2R4W.JLPzwfKJ.isVisible = False



































































































                        ZwNS2R4W.f7Md1glS.isVisible = False



































































































                        ZwNS2R4W.tmZbm648.isVisible = False



































































































                        ZwNS2R4W.BNSmRj3w.isEnabled = False



































































































                        ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































                        ZwNS2R4W.sSqJdGS2.isEnabled = False



































































































                        ZwNS2R4W.QbrrQGbk.isEnabled = False



































































































                if kgmD6nNg:



































































































                    if ZwNS2R4W.LWDFPN31.selectionCount == 0:



































































































                        ZwNS2R4W.LWDFPN31.hasFocus = True



































































































                        if lMB54F3t is not None:



































































































                            lMB54F3t.opacity = 1



































































































                            if lMB54F3t.isSelectable is False:



































































































                                lMB54F3t.isSelectable = True



































































































                        lMB54F3t = None



































































































                    elif ZwNS2R4W.ps3sJ5RT.selectionCount == 0:



































































































                        ZwNS2R4W.ps3sJ5RT.hasFocus = True



































































































                        Q66BPtdt = ZwNS2R4W.LWDFPN31.selection(0).entity  



































































































                        if Q66BPtdt.opacity != 0.5:



































































































                            Q66BPtdt.opacity = 0.5



































































































                            if Q66BPtdt.isSelectable is True:



































































































                                Q66BPtdt.isSelectable = False



































































































                if HVLm722j == 'selectionBoard':



































































































                    try:



































































































                        if lMB54F3t is not None:



































































































                            if lMB54F3t.opacity != 1:



































































































                                lMB54F3t.opacity = 1



































































































                            lMB54F3t.isSelectable = True



































































































                    except Exception:



































































































                        pass



































































































                    if ZwNS2R4W.LWDFPN31.selectionCount != 0:



































































































                        lMB54F3t = ZwNS2R4W.LWDFPN31.selection(0).entity  



































































































                if ZwNS2R4W.ps3sJ5RT.selectionCount == 0:



































































































                    hFbJcsRM = None  



































































































                if HVLm722j == 'selectionFace' and ZwNS2R4W.ps3sJ5RT.selectionCount != 0:



































































































                    B65gg9kV = ZwNS2R4W.ps3sJ5RT.selection(0).entity  



































































































                    gp2rCsr4 = B65gg9kV



































































































                    hFbJcsRM = b28F624h(B65gg9kV, ZwNS2R4W.tcB3Hj5T.value)



































































































                if HVLm722j == "rotate" and ZwNS2R4W.ps3sJ5RT.selectionCount != 0:



































































































                    SCCnSTpn = cL62qdlC.activeProduct  



































































































                    SCCnSTpn.timeline.markerPosition = cH5Kn9lM



































































































                    if gp2rCsr4 is not None:



































































































                        ZwNS2R4W.ps3sJ5RT.clearSelection()



































































































                        ZwNS2R4W.ps3sJ5RT.addSelection(gp2rCsr4)



































































































                        B65gg9kV = gp2rCsr4



































































































                        hFbJcsRM = b28F624h(B65gg9kV, ZwNS2R4W.tcB3Hj5T.value)



































































































                if (HVLm722j in ['selectionBoard', 'selectionFace', 'flip', 'centered', 'numberOfTenons', 'isSpacing', 'rotate']) and ZwNS2R4W.ps3sJ5RT.selectionCount != 0 and ZwNS2R4W.LWDFPN31.selectionCount != 0:



































































































                    ff334TGJ = ZwNS2R4W.JdLw9ZZr.value



































































































                    TRfFQc4q = ZwNS2R4W.sSqJdGS2.value



































































































                    tkzZvK9Z = ZwNS2R4W.BNSmRj3w.value



































































































                    fB2nlG2K = ZwNS2R4W.BNSmRj3w.expression



































































































                    if ZwNS2R4W.J5JBSfmt.value:



































































































                        if ZwNS2R4W.Lr79LGrP.value == 1:



































































































                            ZwNS2R4W.sSqJdGS2.isEnabled = False



































































































                            ZwNS2R4W.QbrrQGbk.isEnabled = False



































































































                        else:



































































































                            ZwNS2R4W.sSqJdGS2.isEnabled = True



































































































                            ZwNS2R4W.QbrrQGbk.isEnabled = False



































































































                    else:



































































































                        if ZwNS2R4W.Lr79LGrP.value == 1:



































































































                            ZwNS2R4W.sSqJdGS2.isEnabled = True



































































































                            ZwNS2R4W.QbrrQGbk.isEnabled = False



































































































                        else:



































































































                            ZwNS2R4W.sSqJdGS2.isEnabled = True



































































































                            ZwNS2R4W.QbrrQGbk.isEnabled = True



































































































                    if ZwNS2R4W.JdLw9ZZr.value is False:



































































































                        ZwNS2R4W.BNSmRj3w.isEnabled = True



































































































                        ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































                        ZwNS2R4W.gLP8cVZ4.isVisible = False



































































































                        ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































                    else:



































































































                        ZwNS2R4W.BNSmRj3w.isEnabled = False



































































































                        ZwNS2R4W.gLP8cVZ4.isEnabled = True



































































































                        ZwNS2R4W.gLP8cVZ4.isVisible = True



































































































                        ZwNS2R4W.gLP8cVZ4.isEnabled = True



































































































                    if ZwNS2R4W.J5JBSfmt.value:



































































































                        tPBR4wK3 = ZwNS2R4W.Lr79LGrP.value



































































































                        if tPBR4wK3 == 1:



































































































                            TRfFQc4q = (hFbJcsRM.Q2k49HvH - tkzZvK9Z) / 2



































































































                            ZwNS2R4W.sSqJdGS2.value = TRfFQc4q



































































































                        ZwNS2R4W.QbrrQGbk.value = ZwNS2R4W.sSqJdGS2.value



































































































                    w4NzLRJ8 = hFbJcsRM.q8WwJccs.copy()



































































































                    KRqf3P3Q = hFbJcsRM.RdlhV9pK.copy()



































































































                    FLc42Fb1 = hFbJcsRM.Hr7G3whC.copy()



































































































                    sf2rZN44 = hFbJcsRM.GN1922td.copy()



































































































                    if ZwNS2R4W.gz64kP2J.value:



































































































                        w4NzLRJ8, KRqf3P3Q = KRqf3P3Q, w4NzLRJ8



































































































                        FLc42Fb1, sf2rZN44 = sf2rZN44, FLc42Fb1



































































































                    ZwNS2R4W.sSqJdGS2.setManipulator(FLc42Fb1, w4NzLRJ8)



































































































                    ZwNS2R4W.sSqJdGS2.value = TRfFQc4q



































































































                    if not ff334TGJ:



































































































                        LwpFNTt5 = adsk.core.Point3D.create(0, 0, 0)



































































































                        LwpFNTt5.x = FLc42Fb1.x + w4NzLRJ8.x * TRfFQc4q



































































































                        LwpFNTt5.y = FLc42Fb1.y + w4NzLRJ8.y * TRfFQc4q



































































































                        LwpFNTt5.z = FLc42Fb1.z + w4NzLRJ8.z * TRfFQc4q



































































































                        ZwNS2R4W.BNSmRj3w.setManipulator(LwpFNTt5, w4NzLRJ8)



































































































                        ZwNS2R4W.BNSmRj3w.expression = fB2nlG2K



































































































                    else:



































































































                        if ZwNS2R4W.J5JBSfmt.value:



































































































                            jg5Vswsc = TRfFQc4q



































































































                        else:



































































































                            jg5Vswsc = ZwNS2R4W.QbrrQGbk.value



































































































                        vJlqzTl2 = ZwNS2R4W.gLP8cVZ4.value



































































































                        k4DLMHgN = ZwNS2R4W.Lr79LGrP.value



































































































                        G8QwQqTT = (hFbJcsRM.Q2k49HvH - TRfFQc4q - jg5Vswsc - vJlqzTl2 * (k4DLMHgN - 1)) / k4DLMHgN



































































































                        LsHkj1rr = adsk.core.Point3D.create(0, 0, 0)



































































































                        LsHkj1rr.x = FLc42Fb1.x + w4NzLRJ8.x * (TRfFQc4q + G8QwQqTT)



































































































                        LsHkj1rr.y = FLc42Fb1.y + w4NzLRJ8.y * (TRfFQc4q + G8QwQqTT)



































































































                        LsHkj1rr.z = FLc42Fb1.z + w4NzLRJ8.z * (TRfFQc4q + G8QwQqTT)



































































































                        ZwNS2R4W.gLP8cVZ4.setManipulator(LsHkj1rr, w4NzLRJ8)



































































































                    jg5Vswsc = ZwNS2R4W.QbrrQGbk.value



































































































                    ZwNS2R4W.QbrrQGbk.setManipulator(sf2rZN44, KRqf3P3Q)



































































































                    ZwNS2R4W.QbrrQGbk.value = jg5Vswsc



































































































                    if ZwNS2R4W.jR29GP4P.value and not ZwNS2R4W.JdLw9ZZr.value:



































































































                        ZwNS2R4W.BNSmRj3w.isEnabled = False



































































































                        ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































                        ZwNS2R4W.sSqJdGS2.isEnabled = False



































































































                        ZwNS2R4W.QbrrQGbk.isEnabled = False



































































































                if HVLm722j == "offset1" or (ZwNS2R4W.JdLw9ZZr.value and (HVLm722j in ['offset2', 'spacing'])):



































































































                    tkzZvK9Z = ZwNS2R4W.BNSmRj3w.value



































































































                    TRfFQc4q = ZwNS2R4W.sSqJdGS2.value



































































































                    w4NzLRJ8 = ZwNS2R4W.sSqJdGS2.manipulatorDirection



































































































                    w4NzLRJ8.normalize()



































































































                    FLc42Fb1 = ZwNS2R4W.sSqJdGS2.manipulatorOrigin



































































































                    if not ZwNS2R4W.JdLw9ZZr.value:



































































































                        fB2nlG2K = ZwNS2R4W.BNSmRj3w.expression



































































































                        LwpFNTt5 = ZwNS2R4W.BNSmRj3w.manipulatorOrigin



































































































                        LwpFNTt5.x = FLc42Fb1.x + w4NzLRJ8.x * TRfFQc4q



































































































                        LwpFNTt5.y = FLc42Fb1.y + w4NzLRJ8.y * TRfFQc4q



































































































                        LwpFNTt5.z = FLc42Fb1.z + w4NzLRJ8.z * TRfFQc4q



































































































                        ZwNS2R4W.BNSmRj3w.setManipulator(LwpFNTt5, w4NzLRJ8)



































































































                        ZwNS2R4W.BNSmRj3w.expression = fB2nlG2K



































































































                    else:



































































































                        if ZwNS2R4W.J5JBSfmt.value:



































































































                            jg5Vswsc = TRfFQc4q



































































































                        else:



































































































                            jg5Vswsc = ZwNS2R4W.QbrrQGbk.value



































































































                        vJlqzTl2 = ZwNS2R4W.gLP8cVZ4.value



































































































                        k4DLMHgN = ZwNS2R4W.Lr79LGrP.value



































































































                        G8QwQqTT = (hFbJcsRM.Q2k49HvH - TRfFQc4q - jg5Vswsc - vJlqzTl2 * (k4DLMHgN - 1)) / k4DLMHgN



































































































                        LsHkj1rr = adsk.core.Point3D.create(0, 0, 0)



































































































                        LsHkj1rr.x = FLc42Fb1.x + w4NzLRJ8.x * (TRfFQc4q + G8QwQqTT)



































































































                        LsHkj1rr.y = FLc42Fb1.y + w4NzLRJ8.y * (TRfFQc4q + G8QwQqTT)



































































































                        LsHkj1rr.z = FLc42Fb1.z + w4NzLRJ8.z * (TRfFQc4q + G8QwQqTT)



































































































                        ZwNS2R4W.gLP8cVZ4.setManipulator(LsHkj1rr, w4NzLRJ8)



































































































                if HVLm722j == "offset1" and ZwNS2R4W.J5JBSfmt.value:



































































































                    ZwNS2R4W.QbrrQGbk.expression = ZwNS2R4W.sSqJdGS2.expression



































































































                    ZwNS2R4W.QbrrQGbk.isEnabled = False



































































































                if HVLm722j == 'helpButton':



































































































                    Vhssm1gV()



































































































                if HVLm722j in ['offset1', 'offset2', 'length', 'spacing']:



































































































                    rcJ7r114 = True



































































































                else:



































































































                    rcJ7r114 = False



































































































                if HVLm722j == 'selectionFace' and ZwNS2R4W.ps3sJ5RT.selectionCount == 0:



































































































                    ZwNS2R4W.BNSmRj3w.isEnabled = False



































































































                    ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































                    ZwNS2R4W.sSqJdGS2.isEnabled = False



































































































                    ZwNS2R4W.QbrrQGbk.isEnabled = False



































































































                if HVLm722j == 'selectionBoard' and ZwNS2R4W.LWDFPN31.selectionCount == 0:



































































































                    ZwNS2R4W.BNSmRj3w.isEnabled = False



































































































                    ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































                    ZwNS2R4W.sSqJdGS2.isEnabled = False



































































































                    ZwNS2R4W.QbrrQGbk.isEnabled = False



































































































                if HVLm722j == 'depthOffset':



































































































                    if ZwNS2R4W.b3v5Ssk4.value:



































































































                        ZwNS2R4W.dk8l23Jk.isVisible = True



































































































                        ZwNS2R4W.dk8l23Jk.isEnabled = True



































































































                    else:



































































































                        ZwNS2R4W.dk8l23Jk.isVisible = False



































































































                        ZwNS2R4W.dk8l23Jk.isEnabled = False



































































































                if HVLm722j == 'isDovetail':



































































































                    if ZwNS2R4W.V6vvQ6NG.value:



































































































                        ZwNS2R4W.W5GjH93c.isVisible = True



































































































                        ZwNS2R4W.W5GjH93c.isEnabled = True



































































































                    else:



































































































                        ZwNS2R4W.W5GjH93c.isVisible = False



































































































                        ZwNS2R4W.W5GjH93c.isEnabled = False



































































































                if HVLm722j == 'roundCorners':



































































































                    if ZwNS2R4W.jQWPbQr7.value:



































































































                        ZwNS2R4W.LL9wQm1D.isVisible = True



































































































                        ZwNS2R4W.LL9wQm1D.isEnabled = True



































































































                    else:



































































































                        ZwNS2R4W.LL9wQm1D.isVisible = False



































































































                        ZwNS2R4W.LL9wQm1D.isEnabled = False



































































































                if HVLm722j == 'tenonOffset':



































































































                    if ZwNS2R4W.Vf7PTk49.value:



































































































                        ZwNS2R4W.JD2d2QCJ.isVisible = True



































































































                        ZwNS2R4W.JD2d2QCJ.isEnabled = True



































































































                        ZwNS2R4W.cpvnhgc7.isVisible = True



































































































                        ZwNS2R4W.cpvnhgc7.isEnabled = True



































































































                        ZwNS2R4W.JLPzwfKJ.isVisible = True



































































































                    else:



































































































                        ZwNS2R4W.JD2d2QCJ.isVisible = False



































































































                        ZwNS2R4W.JD2d2QCJ.isEnabled = False



































































































                        ZwNS2R4W.cpvnhgc7.isVisible = False



































































































                        ZwNS2R4W.cpvnhgc7.isEnabled = False



































































































                        ZwNS2R4W.JLPzwfKJ.isVisible = False



































































































                if HVLm722j == 'computeSpacing':



































































































                    CL93gkpW = True



































































































                    ZwNS2R4W.Ghjt2RRG.isVisible = False



































































































                    ZwNS2R4W.Fsjlw27N.isVisible = False



































































































                    ZwNS2R4W.S5PV6c1T.isVisible = False



































































































                if HVLm722j == 'evenSpacing':



































































































                    if ZwNS2R4W.jR29GP4P.value:



































































































                        ZwNS2R4W.BNSmRj3w.isEnabled = False



































































































                        ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































                        ZwNS2R4W.sSqJdGS2.isEnabled = False



































































































                        ZwNS2R4W.QbrrQGbk.isEnabled = False



































































































                        if ZwNS2R4W.JdLw9ZZr.value:



































































































                            ZwNS2R4W.JdLw9ZZr.value = False



































































































                    else:



































































































                        if ZwNS2R4W.ps3sJ5RT.selectionCount != 0 and ZwNS2R4W.LWDFPN31.selectionCount != 0:



































































































                            if ZwNS2R4W.JdLw9ZZr.value is False:



































































































                                ZwNS2R4W.BNSmRj3w.isEnabled = True



































































































                                ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































                                ZwNS2R4W.gLP8cVZ4.isVisible = False



































































































                                ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































                            else:



































































































                                ZwNS2R4W.BNSmRj3w.isEnabled = False



































































































                                ZwNS2R4W.gLP8cVZ4.isEnabled = True



































































































                                ZwNS2R4W.gLP8cVZ4.isVisible = True



































































































                                ZwNS2R4W.gLP8cVZ4.isEnabled = True



































































































                            if not ZwNS2R4W.J5JBSfmt.value or ZwNS2R4W.Lr79LGrP.value > 1:



































































































                                ZwNS2R4W.sSqJdGS2.isEnabled = True



































































































                            if not ZwNS2R4W.J5JBSfmt.value and ZwNS2R4W.Lr79LGrP.value > 1:



































































































                                ZwNS2R4W.QbrrQGbk.isEnabled = True



































































































                if ZwNS2R4W.jR29GP4P.value:



































































































                    if HVLm722j in ["numberOfTenons", "lengthOffset", 'evenSpacing', 'selectionFace']:



































































































                        if hFbJcsRM is not None:



































































































                            tPBR4wK3 = ZwNS2R4W.Lr79LGrP.value



































































































                            RtRfj2k4 = ZwNS2R4W.h3kD3bPH.value



































































































                            ZwNS2R4W.BNSmRj3w.value = (hFbJcsRM.Q2k49HvH - (RtRfj2k4 * tPBR4wK3 * 2)) / ((tPBR4wK3 * 2) + 1)



































































































                            ZwNS2R4W.sSqJdGS2.value = ZwNS2R4W.BNSmRj3w.value + RtRfj2k4



































































































                            ZwNS2R4W.QbrrQGbk.value = ZwNS2R4W.sSqJdGS2.value



































































































                if HVLm722j == 'isSpacing':



































































































                    if ZwNS2R4W.JdLw9ZZr.value is False:



































































































                        ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































                        ZwNS2R4W.gLP8cVZ4.isVisible = False



































































































                        ZwNS2R4W.gLP8cVZ4.isEnabled = False



































































































                    else:



































































































                        ZwNS2R4W.gLP8cVZ4.isVisible = True



































































































                        ZwNS2R4W.gLP8cVZ4.isEnabled = True



































































































                    if ZwNS2R4W.jR29GP4P.value is True:



































































































                        ZwNS2R4W.jR29GP4P.value = False



































































































                if ZwNS2R4W.ps3sJ5RT.selectionCount != 0 and ZwNS2R4W.LWDFPN31.selectionCount != 0:



































































































                    rmR4rPLm = []



































































































                    if ZwNS2R4W.bF64vM4J.isValidExpression:



































































































                        rmR4rPLm.append(ZwNS2R4W.bF64vM4J.value)



































































































                    if ZwNS2R4W.jQWPbQr7.value:



































































































                        if ZwNS2R4W.sSqJdGS2.isValidExpression and (ZwNS2R4W.sSqJdGS2.isEnabled or ZwNS2R4W.jR29GP4P.value):



































































































                            rmR4rPLm.append(ZwNS2R4W.sSqJdGS2.value)



































































































                        if ZwNS2R4W.QbrrQGbk.isValidExpression and (ZwNS2R4W.QbrrQGbk.isEnabled or ZwNS2R4W.jR29GP4P.value):



































































































                            rmR4rPLm.append(ZwNS2R4W.QbrrQGbk.value)



































































































                    if len(rmR4rPLm) > 0:



































































































                        FDDCqqfp = min(rmR4rPLm)



































































































                        ZwNS2R4W.PSdzp5B5.maximumValue = FDDCqqfp



































































































                        ZwNS2R4W.PSdzp5B5.isMaximumInclusive = True



































































































                        ZwNS2R4W.LL9wQm1D.maximumValue = FDDCqqfp



































































































                        ZwNS2R4W.LL9wQm1D.isMaximumInclusive = True



































































































                if ZwNS2R4W.ps3sJ5RT.selectionCount != 0 and ZwNS2R4W.LWDFPN31.selectionCount != 0 and ZwNS2R4W.JdLw9ZZr.value is False and ZwNS2R4W.Lr79LGrP.value > 1:



































































































                    V1D1W15N = ZwNS2R4W.BNSmRj3w.value



































































































                    if V1D1W15N != 0:



































































































                        ZwNS2R4W.Lr79LGrP.maximumValue = (hFbJcsRM.Q2k49HvH - ZwNS2R4W.sSqJdGS2.value - ZwNS2R4W.QbrrQGbk.value - V1D1W15N) / V1D1W15N + 1



































































































                        ZwNS2R4W.Lr79LGrP.isMaximumInclusive = True



































































































                else:



































































































                    if ZwNS2R4W.Lr79LGrP.maximumValue != 300:



































































































                        ZwNS2R4W.Lr79LGrP.maximumValue = 300



































































































                if HVLm722j == 'key':



































































































                    H6KqqW1G = gm83dVfh.itemById('key').value.upper().strip()  



































































































                    if CL3tjmwr(H6KqqW1G):



































































































                        gm83dVfh.itemById('readonlyTextBox').isVisible = False



































































































                        gm83dVfh.itemById('validKeyTextBox').isVisible = True



































































































                        wC12Jb16()



































































































                        kcPDHw12 = True



































































































                        gm83dVfh.itemById('key').isVisible = False



































































































        except Exception:



































































































            qN9pKtLP()



































































































class Fd5VHRJV(adsk.core.KeyboardEventHandler):



































































































    def __init__(Q7B515Ph):



































































































        super().__init__()



































































































    def notify(Q7B515Ph, j7kLD7nV):



































































































        try:



































































































            if j7kLD7nV.keyCode == adsk.core.KeyCodes.F1KeyCode:



































































































                Vhssm1gV()



































































































        except Exception:



































































































            qN9pKtLP()



































































































class tgSDS4Cz(adsk.core.ValidateInputsEventHandler):



































































































    def __init__(Q7B515Ph):



































































































        super().__init__()



































































































    def notify(Q7B515Ph, gr2bWCKM):



































































































        global cL62qdlC



































































































        global CL93gkpW



































































































        global ZwNS2R4W



































































































        global hFbJcsRM



































































































        try:



































































































            ZwNS2R4W.fbk2MbtH = ZwNS2R4W.Jj7nd432



































































































            ZwNS2R4W.Jj7nd432 = False



































































































            if not CL93gkpW:



































































































                if ZwNS2R4W.LWDFPN31.selectionCount != 1:



































































































                    gr2bWCKM.areInputsValid = False



































































































                    return



































































































                if ZwNS2R4W.ps3sJ5RT.selectionCount != 1:



































































































                    gr2bWCKM.areInputsValid = False



































































































                    Q66BPtdt = ZwNS2R4W.LWDFPN31.selection(0).entity  



































































































                    if Q66BPtdt.opacity != 0.5:



































































































                        Q66BPtdt.opacity = 0.5



































































































                        if Q66BPtdt.isSelectable is True:



































































































                            Q66BPtdt.isSelectable = False



































































































                    cL62qdlC.activeViewport.refresh()



































































































                    return



































































































                H36tFnCN = ZwNS2R4W.bF64vM4J.value



































































































                if H36tFnCN <= 0:



































































































                    gr2bWCKM.areInputsValid = False



































































































                    return



































































































                if ZwNS2R4W.JdLw9ZZr.value is False:



































































































                    if ZwNS2R4W.BNSmRj3w.value <= 0:



































































































                        gr2bWCKM.areInputsValid = False



































































































                        return



































































































                else:



































































































                    if ZwNS2R4W.gLP8cVZ4.value <= 0:



































































































                        gr2bWCKM.areInputsValid = False



































































































                        return



































































































                    if ZwNS2R4W.Lr79LGrP.value <= 1:



































































































                        gr2bWCKM.areInputsValid = False



































































































                        return



































































































                kJ1chGrN = ZwNS2R4W.Lr79LGrP.value



































































































                if int(kJ1chGrN) != kJ1chGrN or kJ1chGrN < 1 or kJ1chGrN >= 300:



































































































                    gr2bWCKM.areInputsValid = False



































































































                    return



































































































                rw4bCR2q = ZwNS2R4W.sSqJdGS2.value



































































































                if rw4bCR2q < 0:



































































































                    gr2bWCKM.areInputsValid = False



































































































                    return



































































































                rKvPh9PQ = ZwNS2R4W.QbrrQGbk.value



































































































                if rKvPh9PQ < 0:



































































































                    gr2bWCKM.areInputsValid = False



































































































                    return



































































































                if ZwNS2R4W.JdLw9ZZr.value is False and kJ1chGrN > 1:



































































































                    V1D1W15N = ZwNS2R4W.BNSmRj3w.value



































































































                    ZCzwDT2b = (hFbJcsRM.Q2k49HvH - rw4bCR2q - rKvPh9PQ - V1D1W15N) / (kJ1chGrN - 1)



































































































                    if ZCzwDT2b <= V1D1W15N:



































































































                        gr2bWCKM.areInputsValid = False



































































































                        return



































































































                gdSFJ4wv = ZwNS2R4W.PSdzp5B5.value



































































































                if gdSFJ4wv < 0 or gdSFJ4wv > H36tFnCN or (ZwNS2R4W.jQWPbQr7.value and gdSFJ4wv > min(rw4bCR2q, rKvPh9PQ)):



































































































                    gr2bWCKM.areInputsValid = False



































































































                    return



































































































                QGd618S5 = ZwNS2R4W.LL9wQm1D.value



































































































                if ZwNS2R4W.jQWPbQr7.value:



































































































                    if QGd618S5 < 0 or QGd618S5 > min(H36tFnCN, rw4bCR2q, rKvPh9PQ):



































































































                        gr2bWCKM.areInputsValid = False



































































































                        return



































































































                if ZwNS2R4W.h3kD3bPH.value < 0:



































































































                    if ZwNS2R4W.h3kD3bPH.value <= - (ZwNS2R4W.BNSmRj3w.value / 2):



































































































                        gr2bWCKM.areInputsValid = False



































































































                        return



































































































                if ZwNS2R4W.Q1Wt9542.value < 0:



































































































                    gr2bWCKM.areInputsValid = False



































































































                    return



































































































                if ZwNS2R4W.b3v5Ssk4.value:



































































































                    if ZwNS2R4W.dk8l23Jk.value < 0:



































































































                        gr2bWCKM.areInputsValid = False



































































































                        return



































































































                if ZwNS2R4W.jQWPbQr7.value:



































































































                    if ZwNS2R4W.LL9wQm1D.value < 0:



































































































                        gr2bWCKM.areInputsValid = False



































































































                        return



































































































                if ZwNS2R4W.Vf7PTk49.value:



































































































                    if ZwNS2R4W.JD2d2QCJ.value < 0:



































































































                        gr2bWCKM.areInputsValid = False



































































































                        return



































































































                    if ZwNS2R4W.cpvnhgc7.value < 0:



































































































                        gr2bWCKM.areInputsValid = False



































































































                        return



































































































                if ZwNS2R4W.V6vvQ6NG.value:



































































































                    fs331zGm = math.degrees(ZwNS2R4W.W5GjH93c.value)



































































































                    if fs331zGm <= -90 or fs331zGm >= 90:



































































































                        gr2bWCKM.areInputsValid = False



































































































                        return



































































































                try:



































































































                    ZwNS2R4W.bF64vM4J.expression



































































































                    ZwNS2R4W.BNSmRj3w.expression



































































































                    ZwNS2R4W.gLP8cVZ4.expression



































































































                    ZwNS2R4W.Lr79LGrP.expression



































































































                    ZwNS2R4W.sSqJdGS2.expression



































































































                    ZwNS2R4W.QbrrQGbk.expression



































































































                    ZwNS2R4W.PSdzp5B5.expression



































































































                    ZwNS2R4W.h3kD3bPH.expression



































































































                    ZwNS2R4W.Q1Wt9542.expression



































































































                    if ZwNS2R4W.b3v5Ssk4.value:



































































































                        ZwNS2R4W.dk8l23Jk.expression



































































































                    if ZwNS2R4W.V6vvQ6NG.value:



































































































                        ZwNS2R4W.W5GjH93c.expression



































































































                    if ZwNS2R4W.jQWPbQr7.value:



































































































                        ZwNS2R4W.LL9wQm1D.expression



































































































                    if ZwNS2R4W.Vf7PTk49.value:



































































































                        ZwNS2R4W.JD2d2QCJ.expression



































































































                        ZwNS2R4W.cpvnhgc7.expression



































































































                except Exception:



































































































                    gr2bWCKM.areInputsValid = False



































































































                    return



































































































            ZwNS2R4W.Jj7nd432 = True



































































































        except Exception:



































































































            qN9pKtLP()



































































































class QB9cqm6r(adsk.core.CommandEventHandler):



































































































    def __init__(Q7B515Ph):



































































































        super().__init__()



































































































    def notify(Q7B515Ph, j7kLD7nV):



































































































        global cL62qdlC



































































































        global P6KQF3wm



































































































        global ZwNS2R4W



































































































        global lMB54F3t



































































































        global CL93gkpW



































































































        try:



































































































            if not CL93gkpW:



































































































                if lMB54F3t is not None:



































































































                    if lMB54F3t.opacity != 0.5:



































































































                        lMB54F3t.opacity = 0.5



































































































                    if lMB54F3t.isSelectable is True:



































































































                        lMB54F3t.isSelectable = False



































































































                if ZwNS2R4W.f7Md1glS.value:



































































































                    PlQW3HjD(True)



































































































                    if ZwNS2R4W.fbk2MbtH is False:



































































































                        cL62qdlC.activeViewport.refresh()



































































































            else:



































































































                WCv2S9m9()



































































































                cL62qdlC.activeViewport.refresh()



































































































        except Exception:



































































































            qN9pKtLP()



































































































class phQ37n32(adsk.core.CommandEventHandler):



































































































    def __init__(Q7B515Ph):



































































































        super().__init__()



































































































    def notify(Q7B515Ph, j7kLD7nV):



































































































        global cL62qdlC



































































































        global P6KQF3wm



































































































        global ZwNS2R4W



































































































        global p169ZFkB



































































































        global kcPDHw12



































































































        global CL93gkpW



































































































        try:



































































































            if kcPDHw12:



































































































                if not CL93gkpW:



































































































                    SCCnSTpn = cL62qdlC.activeProduct  



































































































                    if SCCnSTpn.designType == adsk.fusion.DesignTypes.ParametricDesignType:



































































































                        d9c44dQG = SCCnSTpn.timeline



































































































                        dbhqvMn2 = d9c44dQG.markerPosition



































































































                    PlQW3HjD(False)



































































































                    if SCCnSTpn.designType == adsk.fusion.DesignTypes.ParametricDesignType:



































































































                        if dbhqvMn2 != d9c44dQG.markerPosition:



































































































                            PDl4khfQ = d9c44dQG.timelineGroups.add(dbhqvMn2, d9c44dQG.markerPosition - 1)



































































































                            PDl4khfQ.name = 'MortiseAndTenon'



































































































                    qd7LfHBp = []



































































































                    qd7LfHBp.append(ZwNS2R4W.bF64vM4J.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.BNSmRj3w.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.gLP8cVZ4.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.Lr79LGrP.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.sSqJdGS2.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.QbrrQGbk.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.J5JBSfmt.value)



































































































                    qd7LfHBp.append(ZwNS2R4W.gz64kP2J.value)



































































































                    qd7LfHBp.append(ZwNS2R4W.PSdzp5B5.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.LL9wQm1D.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.h3kD3bPH.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.Q1Wt9542.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.dk8l23Jk.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.JD2d2QCJ.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.cpvnhgc7.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.JLPzwfKJ.value)



































































































                    qd7LfHBp.append(ZwNS2R4W.W5GjH93c.expression)



































































































                    qd7LfHBp.append(ZwNS2R4W.f7Md1glS.value)



































































































                    qd7LfHBp.append(ZwNS2R4W.tmZbm648.isExpanded)



































































































                    qd7LfHBp.append(ZwNS2R4W.wGmH5CNj.value)



































































































                    qd7LfHBp.append(ZwNS2R4W.b3v5Ssk4.value)



































































































                    qd7LfHBp.append(ZwNS2R4W.bV3M5dz6.value)



































































































                    qd7LfHBp.append(ZwNS2R4W.V6vvQ6NG.value)



































































































                    qd7LfHBp.append(ZwNS2R4W.jR29GP4P.value)



































































































                    qd7LfHBp.append(ZwNS2R4W.tcB3Hj5T.value)



































































































                    qd7LfHBp.append(ZwNS2R4W.jQWPbQr7.value)



































































































                    qd7LfHBp.append(ZwNS2R4W.Vf7PTk49.value)



































































































                    qd7LfHBp.append(ZwNS2R4W.JdLw9ZZr.value)



































































































                    SGlFLNcV(qd7LfHBp)



































































































                else:



































































































                    WCv2S9m9()



































































































            else:



































































































                if P6KQF3wm.itemById('key').value != '':  



































































































                    p169ZFkB.messageBox("An incorrect license key has been entered.", "Mortise and Tenon")



































































































                else:



































































































                    p169ZFkB.messageBox("The trial is limited to a preview.", "Mortise and Tenon")



































































































        except Exception:



































































































            qN9pKtLP()



































































































class pJS6qpL1(adsk.core.CommandEventHandler):



































































































    def __init__(Q7B515Ph):



































































































        super().__init__()



































































































    def notify(Q7B515Ph, j7kLD7nV):



































































































        global P6KQF3wm



































































































        global ZwNS2R4W



































































































        global lMB54F3t



































































































        global gp2rCsr4



































































































        global hFbJcsRM



































































































        try:



































































































            P6KQF3wm = None



































































































            ZwNS2R4W = None  



































































































            lMB54F3t = None



































































































            gp2rCsr4 = None  



































































































            hFbJcsRM = None  



































































































        except Exception:



































































































            qN9pKtLP()



































































































class WGv9M3Pw(adsk.core.HTMLEventHandler):



































































































    def __init__(Q7B515Ph):



































































































        super().__init__()



































































































    def notify(Q7B515Ph, sV3bfrlq):



































































































        try:



































































































            zVv1w469 = json.loads(sV3bfrlq.data)



































































































            if 'url' in zVv1w469:



































































































                vHRDm54N = zVv1w469['url']



































































































                if sys.platform.startswith('win') or sys.platform.startswith('cygwin'):



































































































                    os.startfile(vHRDm54N)



































































































                elif sys.platform.startswith('darwin'):



































































































                    subprocess.Popen(['open', vHRDm54N])



































































































        except Exception:



































































































            qN9pKtLP()