Exemplo n.º 1
0
        // public bool childIsTheOne;


        public SkeletalJoint(CustomRigidGroup parent, CustomRigidJoint rigidJoint)
        {
            if (rigidJoint.joints.Count != 1)
            {
                throw new Exception("Not a proper joint");
            }

            asmJoint           = rigidJoint.joints[0].Definition;
            asmJointOccurrence = rigidJoint.joints[0];
            childGroup         = null;
            parentGroup        = parent;
            this.rigidJoint    = rigidJoint;
            if (rigidJoint.groupOne.Equals(parent))
            {
                childGroup = rigidJoint.groupTwo;
            }
            else if (rigidJoint.groupTwo.Equals(parent))
            {
                childGroup = rigidJoint.groupOne;
            }
            else
            {
                throw new Exception("Couldn't match parent group");
            }
            if (childGroup == null)
            {
                throw new Exception("Not a proper joint: No child joint found");
            }

            /*childIsTheOne = childGroup.Contains(asmJointOccurrence.AffectedOccurrenceOne);
             * if (!childIsTheOne && !childGroup.Contains(asmJointOccurrence.AffectedOccurrenceTwo))
             * {
             * throw new Exception("Expected child not found inside assembly joint.");
             * }*/
        }
Exemplo n.º 2
0
        private Joint ExportJoint(AssemblyJoint invJoint)
        {
            var protoJoint = new Joint();

            var header = new Header();

            try { header.Name = invJoint.Name; } catch {}

            header.Uuid = GetOrSetObjectUUID(invJoint);

            protoJoint.Header = header;

            protoJoint.Origin = GetCenterOrRoot(invJoint.Definition);

            try { protoJoint.IsLocked = invJoint.Locked; } catch {}
            try { protoJoint.IsSuppressed = invJoint.Suppressed; } catch {}

            var invJointOccurrenceOne = invJoint.OccurrenceOne;
            var invJointOccurrenceTwo = invJoint.OccurrenceTwo;

            protoJoint.OccurrenceOneUUID = GetOrSetObjectUUID(invJointOccurrenceOne);
            protoJoint.OccurrenceTwoUUID = GetOrSetObjectUUID(invJointOccurrenceTwo);
            jointedComponentUUIDMap[GetOccurrencePath(invJointOccurrenceOne)] = protoJoint.OccurrenceOneUUID;
            jointedComponentUUIDMap[GetOccurrencePath(invJointOccurrenceTwo)] = protoJoint.OccurrenceTwoUUID;

            var assemblyJointDefinition = invJoint.Definition;

            switch (assemblyJointDefinition.JointType)
            {
            case AssemblyJointTypeEnum.kRigidJointType:
                protoJoint.RigidJointMotion = GetRigidJointMotion(assemblyJointDefinition);
                break;

            case AssemblyJointTypeEnum.kRotationalJointType:
                protoJoint.RevoluteJointMotion = GetRevoluteJointMotion(assemblyJointDefinition);
                break;

            case AssemblyJointTypeEnum.kSlideJointType:
                protoJoint.SliderJointMotion = GetSliderJointMotion(assemblyJointDefinition);
                break;

            case AssemblyJointTypeEnum.kCylindricalJointType:
                protoJoint.CylindricalJointMotion = GetCylindricalJointMotion(assemblyJointDefinition);
                break;

            // case AssemblyJointTypeEnum.k: // pinSlot
            // protoJoint.RigidJointMotion = GetRigidJointMotion(assemblyJointDefinition);
            // break;
            case AssemblyJointTypeEnum.kPlanarJointType:
                protoJoint.PinSlotJointMotion = GetPinSlotJointMotion(assemblyJointDefinition);
                break;

            case AssemblyJointTypeEnum.kBallJointType:
                protoJoint.PlanarJointMotion = GetPlanarJointMotion(assemblyJointDefinition);
                break;
            }

            return(protoJoint);
        }
Exemplo n.º 3
0
        public JointData(AssemblyJoint joint, String name)
        {// set all the default values
            Name        = name;
            jointOfType = joint;
            try
            {
                ReferenceKeyManager refKeyMgr = StandardAddInServer.m_inventorApplication.ActiveDocument.ReferenceKeyManager;
                byte[] refKey = new byte[0];
                joint.GetReferenceKey(ref refKey, 0);
                RefKey = refKeyMgr.KeyToString(refKey);
            } catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            Driver        = DriveTypes.NoDriver;
            Wheel         = WheelType.NotAWheel;
            Friction      = FrictionLevel.None;
            Diameter      = InternalDiameter.PointFive;
            Pressure      = Pressure.psi60;
            Stages        = Stages.SingleStageElevator;
            PWMport       = 1;
            PWMport2      = 1;
            CANport       = 1;
            CANport2      = 1;
            DriveWheel    = false;
            PWM           = true;
            InputGear     = 1;
            OutputGear    = 1;
            SolenoidPortA = 1;
            SolenoidPortB = 1;
            RelayPort     = 1;
            HasBrake      = false;
            BrakePortA    = 1;
            BrakePortB    = 1;
            if (joint.Definition.JointType == AssemblyJointTypeEnum.kCylindricalJointType || joint.Definition.JointType == AssemblyJointTypeEnum.kSlideJointType)
            {// if the assembly joint is linear
                Rotating = false;
            }
            else
            {// set the combo box choices to rotating
                Rotating = true;
            }

            HasLimits          = false;
            JointFrictionLevel = 0;
            HasJointFriction   = false;
        }
Exemplo n.º 4
0
 public bool equals(AssemblyJoint j)
 {
     return(j.Equals(jointOfType));
 }
Exemplo n.º 5
0
 public InvalidJointException(string message, AssemblyJoint joint) : base(message)
 {
     this.joint = joint;
 }
Exemplo n.º 6
0
        public void AssemblyJoint()
        {
            #region inventor öffnen

            Application inventorApp = null;
            Document    inventordoc = null;
            // Enable error handling.
            try
            {
                // Try to connect to a running instance of Inventor.
                inventorApp = (Application)Marshal.GetActiveObject("Inventor.Application");
            }
            catch (Exception ex)
            {
                // Connecting to a running instance failed so try to start Inventor.
                try
                {
                    inventorApp = (Application)Activator.CreateInstance(Type.GetTypeFromProgID("Inventor.Application"), true);

                    inventorApp.Visible = true;
                }
                catch (Exception ex2)
                {
                    // Unable to start Inventor.
                    Console.WriteLine("Unable to connect to or start Inventor.");
                    return;
                }
            }
            //System.Threading.Thread.Sleep(5000);
            //inventordoc = inventorApp.Documents.Add(Inventor.DocumentTypeEnum.kPartDocumentObject, "C:\\Users\\Public\\Documents\\Autodesk\\Inventor 2017\\Templates\\English\\Sheet Metal (in).ipt", true);


            #endregion



            #region Create a new assembly document.
            AssemblyDocument asmDoc =
                (AssemblyDocument)inventorApp.Documents.Add
                    (DocumentTypeEnum.kAssemblyDocumentObject,
                    inventorApp.FileManager.GetTemplateFile
                        (DocumentTypeEnum.kAssemblyDocumentObject));

            AssemblyComponentDefinition asmDef =
                asmDoc.ComponentDefinition;

            Matrix trans =
                inventorApp.TransientGeometry.CreateMatrix();
            #endregion


            #region die Bauelemente
            // Place an occurrence into the assembly.
            ComponentOccurrence occ1 =
                asmDef.Occurrences.Add
                    ("Pfad or element like c\\:...",
                    trans);

            // Place a second occurrence with the matrix
            //adjusted so it fits correctly with the
            //first occurrence.
            trans.Cell[1, 4] = 6 * 2.54;
            ComponentOccurrence occ2 =
                asmDef.Occurrences.Add
                    ("Pfad or element like c\\:...",
                    trans);
            #endregion



            // Get Face 1 from occ1 and
            // create a FaceProxy.
            Face face1 =
                (Face)GetNamedEntity(occ1, "Face1");

            // Get Face 2 from occ2 and
            // create a FaceProxy.
            Face face2 =
                (Face)GetNamedEntity(occ2, "Face2");

            // Get Edge 1 from occ2 and
            // create an EdgeProxy.
            Edge Edge1 =
                (Edge)GetNamedEntity(occ2, "Edge1");

            // Get Edge 3 from occ1 and
            // create an EdgeProxy.
            Edge Edge3 =
                (Edge)GetNamedEntity(occ1, "Edge3");



            // Create an intent to the
            // center of Edge1.
            GeometryIntent edge1Intent =
                asmDef.CreateGeometryIntent
                    (Edge1, PointIntentEnum.kMidPointIntent);

            // Create an intent to the center of Edge3.
            GeometryIntent edge3Intent =
                asmDef.CreateGeometryIntent
                    (Edge3, PointIntentEnum.kMidPointIntent);

            // Create two intents to define
            // the geometry for the joint.
            GeometryIntent intentOne =
                asmDef.CreateGeometryIntent
                    (face2, edge1Intent);
            GeometryIntent intentTwo =
                asmDef.CreateGeometryIntent
                    (face1, edge3Intent);

            // Create a rotation joint between the two parts.
            AssemblyJointDefinition jointDef =
                asmDef.Joints.CreateAssemblyJointDefinition
                    (AssemblyJointTypeEnum.kRotationalJointType,
                    intentOne, intentTwo);

            jointDef.FlipAlignmentDirection = false;
            jointDef.FlipOriginDirection    = true;
            AssemblyJoint joint =
                asmDef.Joints.Add(jointDef);

            // Make the joint visible.
            joint.Visible = true;

            // Drive the joint to animate it.
            joint.DriveSettings.StartValue = "0 deg";
            joint.DriveSettings.EndValue   = "180 deg";
            joint.DriveSettings.GoToStart();
            joint.DriveSettings.PlayForward();
            joint.DriveSettings.PlayReverse();
        }