コード例 #1
0
ファイル: myFunctions.cs プロジェクト: AndreasLuka/ALC-C3D-LX
        public static Point3d GetStairInsertPoint(Solid3d stair3d)
        {
            GripDataCollection grips    = new GripDataCollection();
            GetGripPointsFlags bitFlags = GetGripPointsFlags.GripPointsOnly;

            stair3d.GetGripPoints(grips, 0, 0, Application.DocumentManager.MdiActiveDocument.Editor.GetCurrentView().ViewDirection, bitFlags);

            // Grip point [0] is the start point of the polyline defining the stair
            // Grip point [0,1,2] are the points defining the vertical line and grip point [2,3,4] defining the horizontal line of the first step
            Point3d pInsert = grips[0].GripPoint;

            grips.Dispose();

            return(pInsert);
        }
コード例 #2
0
ファイル: myFunctions.cs プロジェクト: AndreasLuka/ALC-C3D-LX
        public static Matrix3d GetStairDisplacment(Solid3d stair3d)
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;

            GripDataCollection grips    = new GripDataCollection();
            GetGripPointsFlags bitFlags = GetGripPointsFlags.GripPointsOnly;

            stair3d.GetGripPoints(grips, 0, 0, ed.GetCurrentView().ViewDirection, bitFlags);

            // Grip point [0] is the start point of the polyline defining the stair

            Vector3d disp = Point3d.Origin.GetVectorTo(grips[0].GripPoint);

            grips.Dispose();

            return(Matrix3d.Displacement(disp));
        }
コード例 #3
0
ファイル: myFunctions.cs プロジェクト: AndreasLuka/ALC-C3D-LX
        public static double GetStairRotationAngle(Solid3d stair3d)
        {
            GripDataCollection grips    = new GripDataCollection();
            GetGripPointsFlags bitFlags = GetGripPointsFlags.GripPointsOnly;

            stair3d.GetGripPoints(grips, 0, 0, Application.DocumentManager.MdiActiveDocument.Editor.GetCurrentView().ViewDirection, bitFlags);

            // Grip point [0] is the start point of the polyline defining the stair
            // Grip point [0,1,2] are the points defining the vertical line and grip point [2,3,4] defining the horizontal line of the first step

            Point2d start   = new Point2d(grips[2].GripPoint.X, grips[2].GripPoint.Y);
            Point2d end     = new Point2d(grips[4].GripPoint.X, grips[4].GripPoint.Y);
            Point3d pInsert = grips[0].GripPoint;

            grips.Dispose();

            return(start.GetVectorTo(end).Angle);
        }
コード例 #4
0
        private ObjectId TrimPickUP(int nodeNumer, int TriangleNumer, double X, double angle)
        {
            //UtilityClasses.ConstantsAndSettings.DoubleGlass_h1
            //UtilityClasses.ConstantsAndSettings.DoubleGlass_h2
            //UtilityClasses.ConstantsAndSettings.Thickness_of_the_Glass
            #region basedata
            Database db = HostApplicationServices.WorkingDatabase;
            Editor   ed = Application.DocumentManager.MdiActiveDocument.Editor;

            ed.WriteMessage("\n");
            ed.WriteMessage(angle.ToString());

            var        node     = container.Nodes[nodeNumer];
            Triangle   TR       = container.Triangles[TriangleNumer];
            quaternion trNormal = TR.Normal.Second - TR.Normal.First;
            trNormal /= trNormal.abs();
            plane trPlane = new plane(TR.Nodes.First, TR.Nodes.Second, TR.Nodes.Third);


            Point3dCollection pColl = new Point3dCollection();
            IntegerCollection iCol1 = new IntegerCollection();
            IntegerCollection iCol2 = new IntegerCollection();



            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                if ((TR.upSolidHandle.First >= 0) && (TR.upSolidHandle.Second != null))
                {
                    try
                    {
                        Solid3d upSolid = tr.GetObject(GlobalFunctions.GetObjectId(TR.upSolidHandle.Second), OpenMode.ForWrite) as Solid3d;
                        upSolid.GetGripPoints(pColl, iCol1, iCol2);
                    }
                    catch { }
                }
            }


            Bend bend1 = container.Bends[TR.GetFirstBendNumer()];
            Bend bend2 = container.Bends[TR.GetSecondBendNumer()];
            Bend bend3 = container.Bends[TR.GetThirdBendNumer()];
            #endregion

            List <Bend> bends = new List <Bend>();
            if ((bend1.StartNodeNumer == nodeNumer) || (bend1.EndNodeNumer == nodeNumer))
            {
                bends.Add(bend1);
            }
            if ((bend2.StartNodeNumer == nodeNumer) || (bend2.EndNodeNumer == nodeNumer))
            {
                bends.Add(bend2);
            }
            if ((bend3.StartNodeNumer == nodeNumer) || (bend3.EndNodeNumer == nodeNumer))
            {
                bends.Add(bend3);
            }

            if (bends.Count != 2)
            {
                MessageBox.Show("Only two Bends are connected at one point !", "E R R O R");
                return(ObjectId.Null);
            }

            if (bends[0].IsFictive() || bends[1].IsFictive())
            {
                return(ObjectId.Null);
            }

            quaternion Q0 = node.Position;
            quaternion Q1 = (bends[0].Start + bends[0].End) / 2.0;
            quaternion Q2 = (bends[1].Start + bends[1].End) / 2.0;

            // coorinat systems for plane points calculate
            Q1 = Q1 - Q0; Q1 /= Q1.abs(); Q1 *= X; Q1 = Q0 + Q1;
            Q2 = Q2 - Q0; Q2 /= Q2.abs(); Q2 *= X; Q2 = Q0 + Q2;

            UCS ucs = new UCS(Q0, (Q1 + Q2) / 2.0, Q2);
            ucs = new UCS(Q0, ucs.ToACS(new quaternion(0, 0, 100, 0)), ucs.ToACS(new quaternion(0, 100, 0, 0)));

            #region UP glass

            double     dist = (node.Position - (quaternion)pColl[0]).abs();
            quaternion pick = new quaternion();

            foreach (Point3d p in pColl)
            {
                quaternion q = (quaternion)p;
                double     z = (node.Position - q).abs();

                if (z < dist)
                {
                    dist = z;
                    pick = new quaternion(0, p.X, p.Y, p.Z);
                }
            }
            pColl.Clear(); pColl.Dispose();
            iCol1.Clear();
            iCol1.Clear();
            #endregion


            ucs.o = pick;
            Q1    = pick + Q1 - Q0;
            Q2    = pick + Q2 - Q0;
            Q0    = pick;

            // UtilityClasses.GlobalFunctions.DrawLine((Point3d)Q0, new Point3d(), 1);

            quaternion t1 = (Q2 - Q1) * 2.0;
            quaternion t2 = (Q1 - Q2) * 2.0;
            Q1 = Q1 + t2;
            Q2 = Q2 + t1;

            Matrix3d mat = new Matrix3d(ucs.GetAutoCAD_Matrix3d());
            Q1 = ucs.FromACS(Q1);
            Q2 = ucs.FromACS(Q2);
            quaternion   Q3  = new quaternion(0, Q1.GetX(), -Q1.GetY(), Q1.GetZ());
            quaternion   Q4  = new quaternion(0, Q2.GetX(), -Q2.GetY(), Q2.GetZ());
            quaternion[] arr = { Q1, Q2, Q4, Q3, Q1 };
            ObjectId     obj = ObjectId.Null;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable       acBlkTbl    = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord acBlkTblRec = tr.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                Polyline pol = GlobalFunctions.GetPoly(ref arr);
                //pol.TransformBy(Matrix3d.Displacement(new Point3d().GetVectorTo(new Point3d(0, 0, -100))));
                //pol.TransformBy(mat);

                //acBlkTblRec.AppendEntity(pol);
                //tr.AddNewlyCreatedDBObject(pol, true);

                try
                {
                    Solid3d sol = new Solid3d();
                    sol.CreateExtrudedSolid(pol, new Point3d(0, 0, 0).GetVectorTo(new Point3d(0, 0, 100)), new SweepOptions());
                    sol.TransformBy(Matrix3d.Displacement(new Point3d().GetVectorTo(new Point3d(0, 0, -50))));
                    sol.TransformBy(mat);
                    acBlkTblRec.AppendEntity(sol);
                    tr.AddNewlyCreatedDBObject(sol, true);
                    obj = sol.ObjectId;
                }
                catch { }

                tr.Commit();
            }

            /*
             * if (obj != ObjectId.Null)
             * {
             *  using (Transaction tr = db.TransactionManager.StartTransaction())
             *  {
             *
             *      Solid3d sol = tr.GetObject(obj, OpenMode.ForWrite) as Solid3d;
             *      Solid3d ent = tr.GetObject(UtilityClasses.GlobalFunctions.GetObjectId(TR.lowSolidHandle.Second), OpenMode.ForWrite) as Solid3d;
             *      ent.BooleanOperation(BooleanOperationType.BoolSubtract, sol);
             *
             *      tr.Commit();
             *  }
             * }*/



            // ed.WriteMessage("\n");
            // ed.WriteMessage(ucs.FromACS(Q0).ToString());
            // ed.WriteMessage("\n-----------------------------\n");

            return(obj);
        }