Exemplo n.º 1
0
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        // Developing `

        private Inventor.UnitVector GetFaceNormalAtPoint(ref Inventor.Face ViewFace, Inventor.Point point)
        {
            Inventor.TransientGeometry TransientGeometry = mInvApplication.TransientGeometry;
            double[] Pnt = new double[0];
            double[] n   = new double[3];
            Pnt[0] = point.X; Pnt[1] = point.X; Pnt[2] = point.X;
            ViewFace.Evaluator.GetNormalAtPoint(ref Pnt, ref n);
            return(TransientGeometry.CreateUnitVector(n[0], n[1], n[2]));
        }
Exemplo n.º 2
0
        private Inventor.UnitVector GetMidPointAtFaceNormal(ref Inventor.Face Face, ref Inventor.Point Point)
        {
            Inventor.SurfaceEvaluator SurfaceEvaluator;
            SurfaceEvaluator = Face.Evaluator;
            double[] CenterPoint = new double[2];
            double[] CtrPoint    = new double[3];
            CenterPoint[0] = (SurfaceEvaluator.ParamRangeRect.MinPoint.X + SurfaceEvaluator.ParamRangeRect.MaxPoint.X) / 2;
            CenterPoint[1] = (SurfaceEvaluator.ParamRangeRect.MinPoint.Y + SurfaceEvaluator.ParamRangeRect.MaxPoint.Y) / 2;

            double[] normal = new double[3];
            SurfaceEvaluator.GetNormal(ref CenterPoint, ref normal);
            SurfaceEvaluator.GetPointAtParam(ref CenterPoint, ref CtrPoint);
            Point = mInvApplication.TransientGeometry.CreatePoint(CtrPoint[0], CtrPoint[1], CtrPoint[2]);
            return(mInvApplication.TransientGeometry.CreateUnitVector(normal[0], normal[1], normal[2]));
        }
Exemplo n.º 3
0
        private void GetFaceDirction(Inventor.SurfaceBody mSurfaceBody)
        {
            foreach (Inventor.Face face in mSurfaceBody.Faces)
            {
                if (face.SurfaceType == Inventor.SurfaceTypeEnum.kPlaneSurface)
                {
                    Inventor.UnitVector YDir;

                    Inventor.Point      FacePoint = face.PointOnFace;
                    Inventor.UnitVector normal    = GetFaceNormalPoint(face, FacePoint);
                    Inventor.UnitVector XDir      = GetXDir(face, FacePoint);
                    YDir = normal.CrossProduct(XDir);
                }
            }
        }
Exemplo n.º 4
0
        private Inventor.UnitVector GetFaceNormal(ref Inventor.Face Face, ref Inventor.Point Point)
        {
            Inventor.UnitVector       UnitVector;
            Inventor.SurfaceEvaluator SurfaceEvaluator = Face.Evaluator;
            double[] Points        = new double[3];
            double[] GuessParams   = new double[2];
            double[] MaxDeviations = new double[2];
            double[] Params        = new double[2];
            double[] normal        = new double[2];
            Inventor.SolutionNatureEnum[] NatureEnum = new Inventor.SolutionNatureEnum[2];

            Points[0] = Point.X; Points[1] = Point.Y; Points[2] = Point.Z;
            SurfaceEvaluator.GetParamAtPoint(ref Points, ref GuessParams, ref MaxDeviations, ref Params, ref NatureEnum);
            SurfaceEvaluator.GetNormal(ref Params, ref normal);
            UnitVector = mInvApplication.TransientGeometry.CreateUnitVector(normal[0], normal[1], normal[2]);
            return(UnitVector);
        }
Exemplo n.º 5
0
        private Inventor.UnitVector GetXDir(ref Inventor.Face Face, ref Inventor.Point Point)
        {
            Inventor.SurfaceEvaluator SurfaceEvaluator;
            SurfaceEvaluator = Face.Evaluator;
            Inventor.UnitVector UnitVector    = null;
            double[]            Points        = new double[3];
            double[]            GuessParam    = new double[2];
            double[]            maxDeviations = new double[2];
            double[]            Params        = new double[2];
            double[]            uTangents     = new double[3];
            double[]            vTangents     = new double[3];

            Inventor.SolutionNatureEnum[] NatureEnum = new Inventor.SolutionNatureEnum[5];

            Points[0] = Point.X;
            Points[1] = Point.Y;
            Points[2] = Point.Z;

            SurfaceEvaluator.GetParamAtPoint(ref Points, ref GuessParam, ref maxDeviations, ref Params, ref NatureEnum);

            SurfaceEvaluator.GetTangents(ref Params, ref uTangents, ref vTangents);
            UnitVector = mInvApplication.TransientGeometry.CreateUnitVector(uTangents[0], uTangents[1], uTangents[2]);
            return(UnitVector);
        }
Exemplo n.º 6
0
        private void UserInputEvents_OnSelect(Inventor.ObjectsEnumerator JustSelectedEntities, ref Inventor.ObjectCollection MoreSelectedEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
        {
            if (View.Parent != null)
            {
                Inventor.Document Document = (Inventor.Document)View.Parent;
                if (Document.DocumentType == Inventor.DocumentTypeEnum.kAssemblyDocumentObject)
                {
                    Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)Document;

                    OnSelectionChange(ref AssemblyDocument, ref MoreSelectedEntities);
                }
                else
                {
                    Inventor.AssemblyDocument AssemblyDocument = null;
                    JustSelectedEntities = null;
                    OnSelectionChange(ref AssemblyDocument, ref MoreSelectedEntities);
                }
            }
        }
Exemplo n.º 7
0
 private void MouseEventsSink_OnMouseUp(Inventor.MouseButtonEnum Button, Inventor.ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
 {
 }
Exemplo n.º 8
0
 private void UserInputEvents_OnPreSelect(ref object PreSelectEntity, out bool DoHighlight, ref Inventor.ObjectCollection MorePreSelectEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
 {
     DoHighlight = true;
     //roll over
     // MessageBox.Show("On PreSelect");
 }
Exemplo n.º 9
0
 private void UserInputEvents_OnUnSelect(Inventor.ObjectsEnumerator UnSelectedEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
 {
     // MessageBox.Show("On UnSelect");
 }
Exemplo n.º 10
0
 private void UserInputEvents_OnStopPreSelect(Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
 {
     //MessageBox.Show("On Stop PreSelect");
 }
Exemplo n.º 11
0
 private void UserInputEvents_OnDoubleClick(Inventor.ObjectsEnumerator SelectedEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.MouseButtonEnum Button, Inventor.ShiftStateEnum ShiftKeys, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View, Inventor.NameValueMap AdditionalInfo, out Inventor.HandlingCodeEnum HandlingCode)
 {
     HandlingCode = Inventor.HandlingCodeEnum.kEventHandled;
     //MessageBox.Show("On Double Click");
 }
Exemplo n.º 12
0
        private void SetDrawingView(Inventor.SurfaceBody mSurfaceBody, ref Inventor.Camera Camera, Inventor.Face TargetFace)
        {
            if (TargetFace != null)
            {
                if (!TargetFace.IsParamReversed)
                {
                    if (TargetFace.Geometry is Inventor.Plane)
                    {
                        //Inventor.Face TargetFace = Face;
                        Inventor.Point      FacePoint      = TargetFace.PointOnFace;
                        Inventor.UnitVector Normal         = GetFaceNormal(ref TargetFace, ref FacePoint);
                        Inventor.UnitVector UplDirection   = mInvApplication.TransientGeometry.CreateUnitVector(0, 1, 0);
                        Inventor.UnitVector Z_PosDirection = mInvApplication.TransientGeometry.CreateUnitVector(0, 0, 1);
                        Inventor.UnitVector Z_NegDirection = mInvApplication.TransientGeometry.CreateUnitVector(0, 0, -1);
                        Inventor.UnitVector X_PosDirection = mInvApplication.TransientGeometry.CreateUnitVector(1, 0, 0);
                        Inventor.UnitVector Y_PosDirection = mInvApplication.TransientGeometry.CreateUnitVector(0, 1, 0);
                        Inventor.UnitVector X_NegDirection = mInvApplication.TransientGeometry.CreateUnitVector(-1, 0, 0);
                        Inventor.UnitVector Y_NegDirection = mInvApplication.TransientGeometry.CreateUnitVector(0, -1, 0);
                        if (Z_PosDirection.IsEqualTo(Normal))
                        {
                            if (GetExtents(mSurfaceBody) == "X")
                            {
                                UplDirection = Y_NegDirection;
                            }
                            else if (GetExtents(mSurfaceBody) == "Y")
                            {
                                UplDirection = X_NegDirection;
                            }
                            else if (GetExtents(mSurfaceBody) == "Z")
                            {
                                UplDirection = GetXDir(ref TargetFace, ref FacePoint);
                            }
                            FacePoint = Camera.Eye.Copy();
                            FacePoint.TranslateBy(GetMidPointAtFaceNormal(ref TargetFace).AsVector());
                            Camera.Target = FacePoint;

                            Camera.UpVector = UplDirection;

                            Camera.Fit();
                            Camera.Apply();
                        }
                        else if (Z_NegDirection.IsEqualTo(Normal))
                        {
                            if (GetExtents(mSurfaceBody) == "X")
                            {
                                UplDirection = Y_PosDirection;
                            }
                            else if (GetExtents(mSurfaceBody) == "Y")
                            {
                                UplDirection = X_PosDirection;
                            }
                            else if (GetExtents(mSurfaceBody) == "Z")
                            {
                                UplDirection = GetXDir(ref TargetFace, ref FacePoint);
                            }

                            FacePoint = Camera.Eye.Copy();
                            FacePoint.TranslateBy(GetMidPointAtFaceNormal(ref TargetFace).AsVector());
                            Camera.Target = FacePoint;

                            Camera.UpVector = UplDirection;

                            Camera.Fit();
                            Camera.Apply();
                        }
                    }
                }
            }
        }
Exemplo n.º 13
0
        private void UserInputEvents_OnSelect(Inventor.ObjectsEnumerator JustSelectedEntities, ref Inventor.ObjectCollection MoreSelectedEntities, Inventor.SelectionDeviceEnum SelectionDevice, Inventor.Point ModelPosition, Inventor.Point2d ViewPosition, Inventor.View View)
        {
            if (View.Parent != null)
            {
                Inventor.Document         Document         = (Inventor.Document)View.Parent;
                Inventor.AssemblyDocument AssemblyDocument = (Inventor.AssemblyDocument)Document;

                if (JustSelectedEntities.Count > 0)
                {
                    for (int i = JustSelectedEntities.Count; i >= 1; i--)
                    {
                        GetInventorObjType(JustSelectedEntities[i]);
                    }
                }
            }
        }