Exemplo n.º 1
0
 public SketchBlur(SketchPoint center, int motionAngle, double radius, SketchBlurType blurType)
 {
     Center      = center;
     MotionAngle = motionAngle;
     Radius      = radius;
     BlurType    = blurType;
 }
Exemplo n.º 2
0
        public SketchOp(PartDocument doc)
        {
            this.doc = doc;
            if (doc.ActivatedObject is PlanarSketch)
            {
                ps  = doc.ActivatedObject as PlanarSketch;
                sl1 = addLine();
                sl2 = findLine(sl1);
                //sl2.Construction = true;
                SketchLine tmp = findLine(sl2);
//                 tmp.Construction = true;
//                 tmp = findLine(tmp);
//                 tmp.Construction = true;
                //addMidConsraint(sl);
                sl = addPerpendicular(sl1, sl2);

                //addMidConsraint(sl2);
                sl3 = addPerpendicular(sl2, sl1, sl);
                //ps.GeometricConstraints.AddCoincident(sl.EndSketchPoint as SketchEntity, sl3.EndSketchPoint as SketchEntity);

                //sp = ps.SketchPoints.Add(sl.Geometry.MidPoint);
                sp = addPoint(sl1, sl2);
                addDimConstr(sp, sl, Macros.StandardAddInServer.data.parX);
                addDimConstr(sp, sl3, Macros.StandardAddInServer.data.parY);
                addAttr(doc as Document, sl1, sp, tmp.Construction);
                //doc.Update();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 创建两点间距离约束
        /// </summary>
        /// <param name="osketch"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="value"></param>
        void CreateTwoPointDistanceConstraint(PlanarSketch osketch, SketchPoint p1, SketchPoint p2, double value)
        {
            Point2d p = InventorTool.TranGeo.CreatePoint2d((p1.Geometry.X + p2.Geometry.X) / 2 + 1, (p1.Geometry.Y + p2.Geometry.Y) / 2 + 1);
            TwoPointDistanceDimConstraint Constraint1 = osketch.DimensionConstraints.AddTwoPointDistance(p1, p2, DimensionOrientationEnum.kAlignedDim, p);

            Constraint1.Parameter.Value = value;
        }
Exemplo n.º 4
0
        public int addPoint(SketchPoint point)     //加入点(被取代)
        {
            KeyValuePair <int, int> temID = new KeyValuePair <int, int>(point.GetID()[0], point.GetID()[1]);

            if (!idToIndex.ContainsKey(temID))
            {
                for (int i = 0; i < pois.Count; i++)
                {
                    if (point.X == pois[i].x && point.Y == pois[i].y && point.Z == pois[i].z)
                    {
                        return(i);
                    }
                }

                newPoint temPoint = new newPoint(point);
                pois.Add(temPoint);
                temPoint.setIndex(pois.Count - 1);
                idToIndex.Add(temID, pois.Count - 1);
                indexToId.Add(pois.Count - 1, temID);
                return(pois.Count - 1);
            }
            else
            {
                return(idToIndex[temID]);
            }
        }
Exemplo n.º 5
0
        protected void ResetRectangle()
        {
            if (_mouseEvents != null)
            {
                _mouseEvents.OnMouseMove  -= _onMouseMove_Delegate;
                _onMouseMove_Delegate      = null;
                _mouseEvents.OnMouseClick -= _onMouseClick_Delegate;
                _onMouseClick_Delegate     = null;
                _mouseEvents = null;
            }

            _rectangleLines                        = null;
            _horizontalMidPointAlign               = null;
            _verticalMidPointAlign                 = null;
            _userInputEvents.OnContextMenu        -= _userInputEvents_OnContextMenuDelegate;
            _userInputEvents_OnContextMenuDelegate = null;
            _planarSketch  = null;
            _drawingSketch = null;
            _secondSelectedSketchEntity = null;
            _inferredOriginPoint        = null;
            _inferredFinalPositionPoint = null;
            _firstSelectedSketchEntity  = null;
            _pickedPoint2d                  = null;
            _pickedSketchPoint              = null;
            _rectangleOriginSketchPoint     = null;
            _rectangleCoordSet              = null;
            _rectanglePointCoords           = null;
            _rectangleInteractionGraphics   = null;
            _rectangleGraphicsColorSet      = null;
            _interactionEvents.OnTerminate -= _onTerminate_Delegate;
            _interactionEvents.Stop();
            _interactionEvents = null;
        }
Exemplo n.º 6
0
        static public void addCutDef(SheetMetalComponentDefinition smcd, Double a, Double b, string name = "Паз")
        {
            try
            {
                SketchBlockDefinition d = smcd.SketchBlockDefinitions[name];
                return;
            }
            catch (Exception)
            {
            }
            SketchBlockDefinition def = smcd.SketchBlockDefinitions.Add(name);
            TransientGeometry     tg  = Macros.StandardAddInServer.m_inventorApplication.TransientGeometry;
            Point2d     pt            = tg.CreatePoint2d();
            SketchPoint origin        = def.SketchPoints.Add(pt, false);

            def.GeometricConstraints.AddGround((SketchEntity)origin);
            SketchLine sl1, sl2, sl3;
            SketchEntitiesEnumerator en = def.SketchLines.AddAsTwoPointRectangle(tg.CreatePoint2d(-b / 2, -a / 2), tg.CreatePoint2d(b / 2, a / 2));

            sl1 = (SketchLine)en[2]; sl2 = (SketchLine)en[4];
            sl3 = midleLine(sl1, sl2);

            //foreach (DimensionConstraint item in def.DimensionConstraints)
            //{
            //    item.Delete();
            //}
        }
Exemplo n.º 7
0
        public void addDimConstr(SketchPoint p, SketchLine sl, Parameter par = null)
        {
            Vector2d v = ut.normal(sl.StartSketchPoint.Geometry, sl.EndSketchPoint.Geometry), v1 = p.Geometry.VectorTo(sl.StartSketchPoint.Geometry);

            if (v.AngleTo(v1) > Math.PI / 2)
            {
                v.ScaleBy(-1);
            }
            pt = p.Geometry.Copy();
            pt.TranslateBy(v);
            ObjectsEnumerator en = sl.Geometry.IntersectWithCurve(I.tg.CreateLineSegment2d(p.Geometry, pt), 0.1);

            if (en != null && en.Count != 0)
            {
                pt = en[1] as Point2d;
            }
            OffsetDimConstraint offs = ps.DimensionConstraints.AddOffset(sl, p as SketchEntity, ut.midPt(p.Geometry, pt, p.Geometry.DistanceTo(pt) / 5, 0), false);

            if (par != null)
            {
                offs.Parameter.Expression = par.Name;
            }
            else
            {
                offs.Parameter.Value = 0;
            }
        }
Exemplo n.º 8
0
        private static List <SketchCurvePoint> StraightLine(SketchPoint p1, SketchPoint p2)
        {
            var points = new List <SketchCurvePoint>()
            {
                new SketchCurvePoint(
                    point: p1,
                    curveFrom: p1,
                    curveTo: p1,
                    cornerRadius: 0,
                    mode: SketchCurvePoint.CurveMode.Line,
                    hasCurveFrom: false,
                    hasCurveTo: false
                    ),
                new SketchCurvePoint(
                    point: p2,
                    curveFrom: p2,
                    curveTo: p2,
                    cornerRadius: 0,
                    mode: SketchCurvePoint.CurveMode.Line,
                    hasCurveFrom: true,
                    hasCurveTo: true)
            };

            return(points);
        }
Exemplo n.º 9
0
        public void addMidConsraint(SketchLine line)
        {
            pt = line.Geometry.MidPoint;
            SketchPoint s = ps.SketchPoints.Add(pt, false);

            ps.GeometricConstraints.AddMidpoint(s, sl);
        }
Exemplo n.º 10
0
 static public RadiusDimConstraint addRadius(SketchEntity ent, SketchPoint sp1, SketchPoint sp2, string name)
 {
     mp  = u.midPt(sp1.Geometry, sp2.Geometry);
     val = ps.DimensionConstraints.AddRadius(ent, mp);
     addName <RadiusDimConstraint>(name, "R");
     return(val as RadiusDimConstraint);
 }
Exemplo n.º 11
0
 UxFloat2 SketchPointToFloat2(SketchPoint point)
 {
     return(new UxFloat2(
                (float)point.X,
                (float)point.Y
                ));
 }
Exemplo n.º 12
0
 public SketchShadow(bool isEnabled, SketchColor color, SketchPoint offset, double blurRadius, double spread)
 {
     IsEnabled  = isEnabled;
     Color      = color;
     Offset     = offset;
     BlurRadius = blurRadius;
     Spread     = spread;
 }
Exemplo n.º 13
0
        SketchSegment Line(SketchPoint a, SketchPoint b)
        {
            clear();
            SketchSegment segment = Segments[iSegments++] = Model.SketchManager.CreateLine(a.X, a.Y, 0, b.X, b.Y, 0);

            clear(); a.Select(true); select(iSegments - 1, "a"); merge();
            clear(); b.Select(true); select(iSegments - 1, "b"); merge();
            return(segment);
        }
Exemplo n.º 14
0
        public SketchPoint draw(SketchPoint sp, double L)
        {
            dir.Normalize();
            dir.ScaleBy(L);
            Point2d pt = sp.Geometry;

            pt.TranslateBy(dir);
            return(ps.SketchPoints.Add(pt));
        }
Exemplo n.º 15
0
 public static void writeXml(this SketchPoint point,
                             XmlWriter writer, string nameElement)
 {
     writer.WriteStartElement(nameElement);
     writer.WriteString(Convert.ToString(point.X * 1000.0) + ", ");
     writer.WriteString(Convert.ToString(point.Y * 1000.0) + ", ");
     writer.WriteString(Convert.ToString(point.Z * 1000.0));
     writer.WriteEndElement();
 }
Exemplo n.º 16
0
        public static void Build(InventorAPI api, string formName)
        {
            PlanarSketch[]   sketch  = new PlanarSketch[4];
            Profile[]        profile = new Profile[4];
            SketchPoint[]    point   = new SketchPoint[4];
            SketchLine[]     line    = new SketchLine[4];
            RevolveFeature[] revolve = new RevolveFeature[4];
            // Создание цилиндра
            sketch[0]  = api.Sketch(api.GetCompDef().WorkPlanes[3]);
            point[0]   = api.Point(sketch[0], 0, 0);
            point[1]   = api.Point(sketch[0], 0, H / 10);
            point[2]   = api.Point(sketch[0], D1 / 10 / 2, H / 10);
            point[3]   = api.Point(sketch[0], D1 / 10 / 2, 0);
            line[0]    = api.Line(sketch[0], point[0], point[1]);
            line[1]    = api.Line(sketch[0], point[1], point[2]);
            line[2]    = api.Line(sketch[0], point[2], point[3]);
            line[3]    = api.Line(sketch[0], point[3], point[0]);
            profile[0] = api.Profile(sketch[0]);
            revolve[0] = api.Revolve(profile[0], line[0], 0);
            // Создание пружины
            sketch[1]  = api.Sketch(api.GetCompDef().WorkPlanes[3]);
            point[0]   = api.Point(sketch[1], D1 / 10 / 2, 0);
            point[1]   = api.Point(sketch[1], D / 10 / 2, 0);
            point[3]   = api.Point(sketch[1], D1 / 10 / 2, T / 10);
            line[0]    = api.Line(sketch[1], point[0], point[1]);
            line[1]    = api.Line(sketch[1], point[1], point[3]);
            line[2]    = api.Line(sketch[1], point[3], point[0]);
            profile[1] = api.Profile(sketch[1]);
            var coil = api.GetCompDef().Features.CoilFeatures.AddByPitchAndHeight(profile[1], api.GetCompDef().WorkAxes[2], H1 / 10, H2 / 10, PartFeatureOperationEnum.kJoinOperation, false, false, 0, false, 0, 0, true);

            // Верхняя граница пружины
            sketch[2]  = api.Sketch(api.GetCompDef().WorkPlanes[3]);
            point[0]   = api.Point(sketch[2], 0, H2 / 10);
            point[1]   = api.Point(sketch[2], 0, H2 / 10 + T / 10);
            point[2]   = api.Point(sketch[2], D / 10 / 2, H2 / 10 + T / 10);
            point[3]   = api.Point(sketch[2], D / 10 / 2, H2 / 10);
            line[0]    = api.Line(sketch[2], point[0], point[1]);
            line[1]    = api.Line(sketch[2], point[1], point[2]);
            line[2]    = api.Line(sketch[2], point[2], point[3]);
            line[3]    = api.Line(sketch[2], point[3], point[0]);
            profile[2] = api.Profile(sketch[2]);
            revolve[2] = api.Revolve(profile[2], line[0], 0);
            // Крепление
            sketch[3]  = api.Sketch(api.GetCompDef().WorkPlanes[3]);
            point[0]   = api.Point(sketch[3], 0, H3 / 10);
            point[1]   = api.Point(sketch[3], 0, H3 / 10 + A / 10);
            point[2]   = api.Point(sketch[3], D / 10 / 2, H3 / 10 + A / 10);
            point[3]   = api.Point(sketch[3], D / 10 / 2, H3 / 10);
            line[0]    = api.Line(sketch[3], point[0], point[1]);
            line[1]    = api.Line(sketch[3], point[1], point[2]);
            line[2]    = api.Line(sketch[3], point[2], point[3]);
            line[3]    = api.Line(sketch[3], point[3], point[0]);
            profile[3] = api.Profile(sketch[3]);
            revolve[3] = api.Revolve(profile[3], line[0], 0);
            System.Windows.Forms.MessageBox.Show(formName + " завершено.", formName);
        }
Exemplo n.º 17
0
        SketchSegment Line(SketchPoint p, double x, double y)
        {
            clear();
            Vector        b       = ~P(x, y);
            SketchSegment segment = Segments[iSegments++] = Model.SketchManager.CreateLine(p.X, p.Y, 0, b.x, b.y, 0);

            clear(); p.Select(true); select(iSegments - 1, "a"); merge();
            LastPoint = P(x, y);
            return(segment);
        }
Exemplo n.º 18
0
 public AttributeSet AttribSetAdd(SketchPoint ob, string nameAttSet)
 {
     attSets = ob.AttributeSets;
     if (attSets.NameIsUsed[nameAttSet])
     {
         AttribDelete(nameAttSet);
     }
     attSet = attSets.Add(nameAttSet);
     return(attSet);
 }
Exemplo n.º 19
0
 public void setStart(SketchPoint add)
 {
     if (pois.Count == 0)
     {
         pois.Add(add);
     }
     else
     {
         Debug.Print("Error wen storing first point in one loop.");
     }
 }
Exemplo n.º 20
0
        // create CurvePoint representing a straight line with corner radius = 0
        public static SketchCurvePoint LinePoint(double x, double y, double cornerRadius = 0)
        {
            var p = new SketchPoint(x, y);

            return(new SketchCurvePoint(
                       p,
                       p,
                       p,
                       cornerRadius,
                       SketchCurvePoint.CurveMode.Line, false, false
                       ));
        }
Exemplo n.º 21
0
        static public SketchLine midleLine(SketchLine sl1, SketchLine sl2)
        {
            PlanarSketch       ps  = (PlanarSketch)sl1.Parent;
            SketchPoint        sp1 = ps.SketchPoints.Add(sl1.Geometry.MidPoint, false);
            SketchPoint        sp2 = ps.SketchPoints.Add(sl2.Geometry.MidPoint, false);
            SketchLine         sl3 = ps.SketchLines.AddByTwoPoints(sp1, sp2);
            MidpointConstraint mpc = ps.GeometricConstraints.AddMidpoint(sp1, sl1);

            mpc = ps.GeometricConstraints.AddMidpoint(sp2, sl2);
            sl3.Construction = true;
            return(sl3);
        }
Exemplo n.º 22
0
 private static void CubicBezierTo(this StringBuilder svgString,
                                   SketchPoint c0,
                                   SketchPoint c1,
                                   SketchPoint endPoint)
 {
     svgString.Append(" C ")
     .Append(CoordinatesToSvg(c0))
     .Append(" ")
     .Append(CoordinatesToSvg(c1))
     .Append(" ")
     .Append(CoordinatesToSvg(endPoint));
 }
Exemplo n.º 23
0
 static public TwoPointDistanceDimConstraint addTwoPointDist(SketchPoint sp1, SketchPoint sp2, string name, double offset = 0, double scale = 1)
 {
     mp = u.midPt(sp1.Geometry, sp2.Geometry, offset, 0, scale);
     try
     {
         val = ps.DimensionConstraints.AddTwoPointDistance(sp1, sp2, DimensionOrientationEnum.kAlignedDim, mp);
         addName <TwoPointDistanceDimConstraint>(name);
         return(val as TwoPointDistanceDimConstraint);
     }
     catch (System.Exception)
     {
         return(null);
     }
 }
Exemplo n.º 24
0
        public Vector2d addVec(SketchPoint pt, SketchLine dir)
        {
            Vector2d v;

            if (ut.eq(sp.Geometry, dir.StartSketchPoint.Geometry))
            {
                v = dir.StartSketchPoint.Geometry.VectorTo(dir.EndSketchPoint.Geometry);
            }
            else
            {
                v = dir.EndSketchPoint.Geometry.VectorTo(dir.StartSketchPoint.Geometry);
            }
            return(v);
        }
Exemplo n.º 25
0
        public SketchLine findLine(SketchLine sl)
        {
            sp = sl.StartSketchPoint;
            SketchLine line = findPoint(sp, sl);

            if (line != null)
            {
                return(line);
            }
            else
            {
                sp = sl.EndSketchPoint; return(findPoint(sp, sl));
            }
        }
Exemplo n.º 26
0
        public void addAttr(Document doc, SketchLine sl, SketchPoint sp, bool contstr)
        {
            VariableData vd     = new VariableData(doc as Document);
            UnitVector   vec    = sl.Geometry3d.Direction;
            AttributeSet attSet = vd.AttribSetAdd(sp, "dir");

            attSet.Add("X", ValueTypeEnum.kDoubleType, vec.X);
            attSet.Add("Y", ValueTypeEnum.kDoubleType, vec.Y);
            attSet.Add("Z", ValueTypeEnum.kDoubleType, vec.Z);
            if (contstr)
            {
                string val = ut.getRefkey <SketchLine>(doc, sl, 0);
                vd.AttribAdd <SketchPoint, string>(sp, "SL", val, ValueTypeEnum.kStringType);
            }
        }
Exemplo n.º 27
0
 public SketchLine findPoint(SketchPoint sp, SketchLine sl)
 {
     foreach (CoincidentConstraint item in sp.Constraints)
     {
         if (item.EntityOne is SketchLine && !item.EntityOne.Equals(sl))
         {
             return(item.EntityOne as SketchLine);
         }
         if (item.EntityTwo is SketchLine && !item.EntityTwo.Equals(sl))
         {
             return(item.EntityTwo as SketchLine);
         }
     }
     return(null);
 }
Exemplo n.º 28
0
        public int findPoint(SketchPoint point)     //通过点的源数据找到点的索引
        {
            KeyValuePair <int, int> ID = new KeyValuePair <int, int>(point.GetID()[0], point.GetID()[1]);

            //int id1 = point.GetID()[0];
            //int id2 = point.GetID()[1];
            for (int i = 0; i < pois.Count; i++)
            {
                if (ID.Key == pois[i].ID.Key && ID.Value == pois[i].ID.Value)
                {
                    return(pois[i].index);
                }
            }
            return(-1);
        }
Exemplo n.º 29
0
        private void createPart2()
        {
            // create a new part
            PartDocument            oDoc = (PartDocument)mApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject);
            PartComponentDefinition oDef = oDoc.ComponentDefinition;

            TransientGeometry oTG = mApp.TransientGeometry;

            // create sketch elements
            PlanarSketch oSketch = oDef.Sketches.Add(oDef.WorkPlanes[3]);

            oSketch.SketchLines.AddAsTwoPointRectangle(oTG.CreatePoint2d(-5, -5), oTG.CreatePoint2d(5, 5));

            SketchPoint oSketchPt = oSketch.SketchPoints.Add(oTG.CreatePoint2d(0, 0));

            Profile oProfile = oSketch.Profiles.AddForSolid();
            // create a plate with a hole feature
            ExtrudeDefinition oExtrudDef = oDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kJoinOperation);

            oExtrudDef.SetDistanceExtent(1, PartFeatureExtentDirectionEnum.kPositiveExtentDirection);
            ExtrudeFeature oExtrudeF = oDef.Features.ExtrudeFeatures.Add(oExtrudDef);

            // Create an object collection for the hole center points.
            ObjectCollection oHoleCenters = default(ObjectCollection);

            oHoleCenters = mApp.TransientObjects.CreateObjectCollection();

            oHoleCenters.Add(oSketchPt);

            // create hole feature
            HolePlacementDefinition oHPdef = (HolePlacementDefinition)oDef.Features.HoleFeatures.CreateSketchPlacementDefinition(oHoleCenters);

            HoleFeature oHoleF = oDef.Features.HoleFeatures.AddDrilledByThroughAllExtent(oHPdef, "2", PartFeatureExtentDirectionEnum.kNegativeExtentDirection);

            Face         oFace   = oHoleF.SideFaces[1];
            AttributeSet oAttSet = default(AttributeSet);

            Inventor.Attribute oAtt = null;
            oAttSet = oFace.AttributeSets.Add("demoAttset");
            oAtt    = oAttSet.Add("demoAtt", ValueTypeEnum.kStringType, "namedEdge");
            if (System.IO.File.Exists("c:\temp\test2.ipt"))
            {
                System.IO.File.Delete("c:\temp\test2.ipt");
            }


            oDoc.SaveAs("c:\\temp\\test2.ipt", false);
        }
Exemplo n.º 30
0
 public SketchCurvePoint(
     SketchPoint point,
     SketchPoint curveFrom,
     SketchPoint curveTo,
     double cornerRadius,
     CurveMode mode,
     bool hasCurveFrom,
     bool hasCurveTo)
 {
     Point        = point;
     CurveFrom    = curveFrom;
     CurveTo      = curveTo;
     CornerRadius = cornerRadius;
     Mode         = mode;
     HasCurveFrom = hasCurveFrom;
     HasCurveTo   = hasCurveTo;
 }
        public static void Bounding(IModelDoc2 model, double[] boxFeature)
        {
            SketchManager sketchManager = default(SketchManager);
            SketchPoint[] sketchPoint = new SketchPoint[9];
            SketchSegment[] sketchSegment = new SketchSegment[13];

            Debug.Print("  point1 = " + "(" + boxFeature[0] * 1000.0 + ", " + boxFeature[1] * 1000.0 + ", " + boxFeature[2] * 1000.0 + ") mm");
            Debug.Print("  point2 = " + "(" + boxFeature[3] * 1000.0 + ", " + boxFeature[4] * 1000.0 + ", " + boxFeature[5] * 1000.0 + ") mm");
            model.Insert3DSketch2(true);
            model.SetAddToDB(true);
            model.SetDisplayWhenAdded(false);

            sketchManager = (SketchManager)model.SketchManager;

            // draw points at each corner of bounding box
            sketchPoint[0] = (SketchPoint)sketchManager.CreatePoint(boxFeature[3], boxFeature[1], boxFeature[5]);
            sketchPoint[1] = (SketchPoint)sketchManager.CreatePoint(boxFeature[0], boxFeature[1], boxFeature[5]);
            sketchPoint[2] = (SketchPoint)sketchManager.CreatePoint(boxFeature[0], boxFeature[1], boxFeature[2]);
            sketchPoint[3] = (SketchPoint)sketchManager.CreatePoint(boxFeature[3], boxFeature[1], boxFeature[2]);
            sketchPoint[4] = (SketchPoint)sketchManager.CreatePoint(boxFeature[3], boxFeature[4], boxFeature[5]);
            sketchPoint[5] = (SketchPoint)sketchManager.CreatePoint(boxFeature[0], boxFeature[4], boxFeature[5]);
            sketchPoint[6] = (SketchPoint)sketchManager.CreatePoint(boxFeature[0], boxFeature[4], boxFeature[2]);
            sketchPoint[7] = (SketchPoint)sketchManager.CreatePoint(boxFeature[3], boxFeature[4], boxFeature[2]);

            // now draw bounding box
            sketchSegment[0] = (SketchSegment)sketchManager.CreateLine(sketchPoint[0].X, sketchPoint[0].Y, sketchPoint[0].Z, sketchPoint[1].X, sketchPoint[1].Y, sketchPoint[1].Z);
            sketchSegment[1] = (SketchSegment)sketchManager.CreateLine(sketchPoint[1].X, sketchPoint[1].Y, sketchPoint[1].Z, sketchPoint[2].X, sketchPoint[2].Y, sketchPoint[2].Z);
            sketchSegment[2] = (SketchSegment)sketchManager.CreateLine(sketchPoint[2].X, sketchPoint[2].Y, sketchPoint[2].Z, sketchPoint[3].X, sketchPoint[3].Y, sketchPoint[3].Z);
            sketchSegment[3] = (SketchSegment)sketchManager.CreateLine(sketchPoint[3].X, sketchPoint[3].Y, sketchPoint[3].Z, sketchPoint[0].X, sketchPoint[0].Y, sketchPoint[0].Z);
            sketchSegment[4] = (SketchSegment)sketchManager.CreateLine(sketchPoint[0].X, sketchPoint[0].Y, sketchPoint[0].Z, sketchPoint[4].X, sketchPoint[4].Y, sketchPoint[4].Z);
            sketchSegment[5] = (SketchSegment)sketchManager.CreateLine(sketchPoint[1].X, sketchPoint[1].Y, sketchPoint[1].Z, sketchPoint[5].X, sketchPoint[5].Y, sketchPoint[5].Z);
            sketchSegment[6] = (SketchSegment)sketchManager.CreateLine(sketchPoint[2].X, sketchPoint[2].Y, sketchPoint[2].Z, sketchPoint[6].X, sketchPoint[6].Y, sketchPoint[6].Z);
            sketchSegment[7] = (SketchSegment)sketchManager.CreateLine(sketchPoint[3].X, sketchPoint[3].Y, sketchPoint[3].Z, sketchPoint[7].X, sketchPoint[7].Y, sketchPoint[7].Z);
            sketchSegment[8] = (SketchSegment)sketchManager.CreateLine(sketchPoint[4].X, sketchPoint[4].Y, sketchPoint[4].Z, sketchPoint[5].X, sketchPoint[5].Y, sketchPoint[5].Z);
            sketchSegment[9] = (SketchSegment)sketchManager.CreateLine(sketchPoint[5].X, sketchPoint[5].Y, sketchPoint[5].Z, sketchPoint[6].X, sketchPoint[6].Y, sketchPoint[6].Z);
            sketchSegment[10] = (SketchSegment)sketchManager.CreateLine(sketchPoint[6].X, sketchPoint[6].Y, sketchPoint[6].Z, sketchPoint[7].X, sketchPoint[7].Y, sketchPoint[7].Z);
            sketchSegment[11] = (SketchSegment)sketchManager.CreateLine(sketchPoint[7].X, sketchPoint[7].Y, sketchPoint[7].Z, sketchPoint[4].X, sketchPoint[4].Y, sketchPoint[4].Z);

            model.SetDisplayWhenAdded(true);
            model.SetAddToDB(false);
            model.Insert3DSketch2(true);
        }
        /// <summary>
        /// When the user clicks on a point in the model, this method runs and creates an interaction graphics rectangle. 
        /// It also subscribes to the Mouse Move event to allow for the size of the rectangle to be driven by the location 
        /// of the mouse on the sketch. Ultimately, this method waits for the next click event, in which case it calls a 
        /// new method to actually create the sketched rectangle.  It has separate paths to react to whether it's a part
        /// sketch or a drawing sketch.
        /// </summary>
        /// <param name="button"></param>
        /// <param name="shiftKeys"></param>
        /// <param name="modelPosition"></param>
        /// <param name="viewPosition"></param>
        /// <param name="view"></param>
        protected void OnMouseClick_CreateRectangle(MouseButtonEnum button, ShiftStateEnum shiftKeys, Point modelPosition,
            Point2d viewPosition, Inventor.View view)
        {
            try
            {
                if (button == MouseButtonEnum.kLeftMouseButton)
                {
                    _onMouseMove_Delegate = new MouseEventsSink_OnMouseMoveEventHandler(OnMouseMove_DragCornerOfRectangle);
                    _mouseEvents.OnMouseClick -= _onMouseClick_Delegate;
                    _onMouseClick_Delegate = null;
                    _userInputEvents.OnContextMenu -= _userInputEvents_OnContextMenuDelegate;
                    _userInputEvents_OnContextMenuDelegate = null;

                    if (_inventorApplication.ActiveEditObject is PlanarSketch)
                    {
                        _planarSketch = (PlanarSketch)_inventorApplication.ActiveEditObject;

                        if (_mouseEvents.PointInferences.Count > 0)
                        {
                            _inferredOriginPoint = _mouseEvents.PointInferences[1];

                            switch (_inferredOriginPoint.InferenceType)
                            {
                                case PointInferenceEnum.kPtAtIntersection:
                                    _firstSelectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[1];
                                    _firstInferredIntersectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[2];
                                    break;
                                case PointInferenceEnum.kPtOnCurve:
                                    _firstSelectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[1];
                                    break;
                                case PointInferenceEnum.kPtOnPt:
                                    _firstSelectedSketchEntity = (SketchPoint)_inferredOriginPoint.Entity[1];
                                    _pickedSketchPoint = (SketchPoint)_firstSelectedSketchEntity;
                                    _rectangleOriginSketchPoint = _pickedSketchPoint;
                                    break;
                                case PointInferenceEnum.kPtAtMidPoint:
                                    _firstSelectedSketchEntity = (SketchLine)_inferredOriginPoint.Entity[1];
                                    break;
                            }
                        }

                        _pickedPoint2d = _planarSketch.ModelToSketchSpace(modelPosition);

                        DrawInteractionRectangle();

                        _mouseEvents.OnMouseMove += _onMouseMove_Delegate;
                        _mouseEvents.MouseMoveEnabled = true;
                    }
                    else if (_inventorApplication.ActiveEditObject is DrawingSketch)
                    {
                        _drawingSketch = (DrawingSketch)_inventorApplication.ActiveEditObject;

                        if (_mouseEvents.PointInferences.Count > 0)
                        {
                            _inferredOriginPoint = _mouseEvents.PointInferences[1];

                            switch (_inferredOriginPoint.InferenceType)
                            {
                                case PointInferenceEnum.kPtAtIntersection:
                                    _firstSelectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[1];
                                    _firstInferredIntersectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[2];
                                    break;
                                case PointInferenceEnum.kPtOnCurve:
                                    _firstSelectedSketchEntity = (SketchEntity)_inferredOriginPoint.Entity[1];
                                    break;
                                case PointInferenceEnum.kPtOnPt:
                                    _firstSelectedSketchEntity = (SketchPoint)_inferredOriginPoint.Entity[1];
                                    _pickedSketchPoint = (SketchPoint)_firstSelectedSketchEntity;
                                    _rectangleOriginSketchPoint = _pickedSketchPoint;
                                    break;
                                case PointInferenceEnum.kPtAtMidPoint:
                                    _firstSelectedSketchEntity = (SketchLine)_inferredOriginPoint.Entity[1];
                                    break;
                            }
                        }
                        PointToPoint2d(modelPosition, out _pickedPoint2d);

                        DrawInteractionRectangle();

                        _mouseEvents.OnMouseMove += _onMouseMove_Delegate;
                        _mouseEvents.MouseMoveEnabled = true;
                    }
                    else
                        MessageBox.Show("You must be editing a sketch in order to use this tool.");
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
Exemplo n.º 33
0
 public CoordNeightboors(SketchPoint _point, LineProp _neiOne, LineProp _neiTwo)
 {
     point = _point;
     neiOne = _neiOne;
     neiTwo = _neiTwo;
 }
        protected void ResetRectangle()
        {
            if (_mouseEvents != null)
            {
                _mouseEvents.OnMouseMove -= _onMouseMove_Delegate;
                _onMouseMove_Delegate = null;
                _mouseEvents.OnMouseClick -= _onMouseClick_Delegate;
                _onMouseClick_Delegate = null;
                _mouseEvents = null;
            }

            _rectangleLines = null;
            _horizontalMidPointAlign = null;
            _verticalMidPointAlign = null;
            _userInputEvents.OnContextMenu -= _userInputEvents_OnContextMenuDelegate;
            _userInputEvents_OnContextMenuDelegate = null;
            _planarSketch = null;
            _drawingSketch = null;
            _secondSelectedSketchEntity = null;
            _inferredOriginPoint = null;
            _inferredFinalPositionPoint = null;
            _firstSelectedSketchEntity = null;
            _pickedPoint2d = null;
            _pickedSketchPoint = null;
            _rectangleOriginSketchPoint = null;
            _rectangleCoordSet = null;
            _rectanglePointCoords = null;
            _rectangleInteractionGraphics = null;
            _rectangleGraphicsColorSet = null;
            _interactionEvents.OnTerminate -= _onTerminate_Delegate;
            _interactionEvents.Stop();
            _interactionEvents = null;
        }
Exemplo n.º 35
0
 public LineProp(string _lineName, SketchPoint _startPoint, SketchPoint _endPoint)
 {
     lineName = _lineName;
     startPoint = _startPoint;
     endPoint = _endPoint;
 }