Esempio n. 1
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;
        }
Esempio n. 2
0
        internal void PlaceWorkGeometryForContsraints(PartComponentDefinition layoutComponentDefinition, ComponentOccurrence layoutOccurrence, int moduleNumber)
        {
            PartDocument        partDoc       = (PartDocument)layoutComponentDefinition.Document;
            ReferenceKeyManager refKeyManager = partDoc.ReferenceKeyManager;

            //TODO: Property ModuleId can be factored out and _binder.ContextData can be used instead.
            ModuleId = moduleNumber;

            for (int i = 0; i < PointObjects.Count; i++)
            {
                //Each ModuleObject needs to have its ContextManager set.
                PointObjects[i].Binder.ContextManager.BindingContextManager = refKeyManager;
                WorkPoint workPoint;
                if (PointObjects[i].Binder.GetObjectFromTrace <WorkPoint>(out workPoint))
                {
                    Inventor.Point newLocation = PersistenceManager.InventorApplication.TransientGeometry.CreatePoint(InternalModulePoints[i].X,
                                                                                                                      InternalModulePoints[i].Y,
                                                                                                                      InternalModulePoints[i].Z);

                    workPoint.SetFixed(InternalModulePoints[i].ToPoint());
                }

                else
                {
                    workPoint = layoutComponentDefinition.WorkPoints.AddFixed(InternalModulePoints[i].ToPoint(), false);
                    PointObjects[i].Binder.SetObjectForTrace <WorkPoint>(workPoint, ModuleUtilities.ReferenceKeysSorter);
                }

                //workPoint.Visible = false;

                object workPointProxyObject;
                layoutOccurrence.CreateGeometryProxy(workPoint, out workPointProxyObject);
                LayoutWorkPointProxies.Add((WorkPointProxy)workPointProxyObject);
                LayoutWorkPoints.Add(workPoint);
            }

            //If we will have more than 2 constraints, it will help assembly stability later
            //if we have a plane to constrain to first.
            if (InternalModulePoints.Count > 2)
            {
                WorkPlane workPlane;
                //TODO: Is this a good idea? Why is this a list? Will we ever have more
                //than work plane?
                PlaneObjects[0].Binder.ContextManager.BindingContextManager = refKeyManager;
                if (PlaneObjects[0].Binder.GetObjectFromTrace <WorkPlane>(out workPlane))
                {
                    if (workPlane.DefinitionType == WorkPlaneDefinitionEnum.kThreePointsWorkPlane)
                    {
                        workPlane.SetByThreePoints(LayoutWorkPoints[0], LayoutWorkPoints[1], LayoutWorkPoints[2]);
                        LayoutWorkPlane = workPlane;
                        object wPlaneProxyObject;
                        layoutOccurrence.CreateGeometryProxy(workPlane, out wPlaneProxyObject);
                        LayoutWorkPlaneProxy = (WorkPlaneProxy)wPlaneProxyObject;
                    }
                }
                else
                {
                    //If the first three points are colinear, adding a workplane will fail.  We will check the area of a triangle
                    //described by the first three points. If the area is very close to 0, we can assume these points are colinear, and we should
                    //not attempt to construct a work plane from them.
                    Inventor.Point pt1 = LayoutWorkPoints[0].Point;
                    Inventor.Point pt2 = LayoutWorkPoints[1].Point;
                    Inventor.Point pt3 = LayoutWorkPoints[2].Point;
                    if (Math.Abs(pt1.X * (pt2.Y - pt3.Y) + pt2.X * (pt3.Y - pt1.Y) + pt3.X * (pt1.Y - pt2.Y)) > .0000001)
                    {
                        workPlane = layoutComponentDefinition.WorkPlanes.AddByThreePoints(LayoutWorkPoints[0], LayoutWorkPoints[1], LayoutWorkPoints[2], false);
                        PlaneObjects[0].Binder.SetObjectForTrace <WorkPlane>(workPlane, ModuleUtilities.ReferenceKeysSorter);
                        workPlane.Grounded = true;
                        //workPlane.Visible = false;
                        LayoutWorkPlane = workPlane;
                        object wPlaneProxyObject;
                        layoutOccurrence.CreateGeometryProxy(workPlane, out wPlaneProxyObject);
                        LayoutWorkPlaneProxy = (WorkPlaneProxy)wPlaneProxyObject;
                    }
                }
            }
        }