示例#1
0
        /// <summary>
        /// 创建水平方向的剖面;
        /// </summary>
        private void CreateHorizontalSection(CMrSection mrSection)
        {
            //判断是否需要创建该剖面或者只是添加零件标记;
            CMrSection mrSameSection = null;

            View.ViewAttributes viewAttributes = new View.ViewAttributes();
            viewAttributes.LoadAttributes(CCommonPara.mSectionAttPath);

            SectionMarkBase.SectionMarkAttributes sectionMarkAttributes = new SectionMarkBase.SectionMarkAttributes();
            sectionMarkAttributes.LoadAttributes(CCommonPara.mSectionMarkNotePath);

            View        sectionView = null;
            SectionMark setionMark  = null;

            double sectionMinY = 0.0;
            double sectionMaxY = 0.0;
            double dblY        = 50;

            mrSection.GetSectionMinYAndMaxY(ref sectionMinY, ref sectionMaxY);

            Point startPt = new Point(mrSection.mSectionMidX, sectionMaxY + dblY, 0);
            Point endPt   = new Point(mrSection.mSectionMidX, sectionMinY - dblY, 0);

            if (CCommonPara.mHorizontalSection == MrSectionOrientation.MrSectionLeft)
            {
                Point tempPt = startPt;
                startPt = endPt;
                endPt   = tempPt;
            }

            bool bNeedCreateView = IsTheSectionNeedCreateView(mrSection, ref mrSameSection);

            if (bNeedCreateView)
            {
                mSectionMarkIndex++;
                mrSection.mSectionMark = mSectionMarkArray[mSectionMarkIndex];

                View.CreateSectionView(mFrontView, startPt, endPt, new Point(0, 0, 0), CCommonPara.mDblSectionUpDepth
                                       , CCommonPara.mDblSectionDownDepth, viewAttributes, sectionMarkAttributes, out sectionView, out setionMark);
            }
            else if (CCommonPara.mbShowSameSectionMark)
            {
                sectionMarkAttributes.MarkName = mrSameSection.mSectionMark;
                setionMark = new SectionMark(mFrontView, startPt, endPt, sectionMarkAttributes);
                setionMark.Insert();
                mFrontView.Modify();
            }
        }
示例#2
0
        public void Modify(PropertyValueChangedEventArgs e)
        {
            string  label   = e.ChangedItem.Label;
            Drawing drawing = drawingHandler.GetActiveDrawing();
            DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetDrawingObjectSelector().GetSelected();

            while (drawingObjectEnum.MoveNext())
            {
                if (drawingObjectEnum.Current is Tekla.Structures.Drawing.View)
                {
                    Tekla.Structures.Drawing.View drawingView = (Tekla.Structures.Drawing.View)drawingObjectEnum.Current;
                    if (label == "Scale")
                    {
                        drawingView.Attributes.Scale = double.Parse(scale);
                    }
                    if (label == "SizeXMin")
                    {
                        drawingView.RestrictionBox.MinPoint.X = double.Parse(sizeXMin);
                    }
                    if (label == "SizeXMax")
                    {
                        drawingView.RestrictionBox.MaxPoint.X = double.Parse(sizeXMax);
                    }
                    if (label == "SizeYMin")
                    {
                        drawingView.RestrictionBox.MinPoint.Y = double.Parse(sizeYMin);
                    }
                    if (label == "SizeYMax")
                    {
                        drawingView.RestrictionBox.MaxPoint.Y = double.Parse(sizeYMax);
                    }
                    if (label == "SizeDepthDown")
                    {
                        drawingView.RestrictionBox.MinPoint.Z = double.Parse(sizeDepthDown) * -1;
                    }
                    if (label == "SizeDepthUp")
                    {
                        drawingView.RestrictionBox.MaxPoint.Z = double.Parse(sizeDepthUp);
                    }
                    if (label == "ViewExtension")
                    {
                        drawingView.Attributes.ViewExtensionForNeighbourParts = double.Parse(viewExtension);
                    }
                    if (label == "FixedViewPlacing")
                    {
                        drawingView.Attributes.FixedViewPlacing = bool.Parse(fixedViewPlacing.ToString());
                    }
                    if (label == "CutParts")
                    {
                        drawingView.Attributes.Shortening.CutParts = bool.Parse(cutParts.ToString());
                    }
                    if (label == "MinimumLength")
                    {
                        drawingView.Attributes.Shortening.MinimumLength = double.Parse(minimumLength);
                    }
                    drawingView.Modify();
                    drawing.CommitChanges();
                }
            }
        }
        /// <summary>
        /// 创建水平方向的剖面;
        /// </summary>
        /// <param name="mrSection"></param>
        private void CreateHorizontalNormalSection(CMrSection mrSection, CMrPart mrPart)
        {
            CMrPart mTopBeam    = CMrBeamDoorManager.GetInstance().mTopBeam;
            CMrPart mBottomBeam = CMrBeamDoorManager.GetInstance().mBottonBeam;

            Point tBLeftTopPt  = mTopBeam.mLeftTopPoint;
            Point tBRightTopPt = mTopBeam.mRightTopPoint;

            Point bBLeftTopPt  = mBottomBeam.mLeftTopPoint;
            Point bBRightTopPt = mBottomBeam.mRightTopPoint;

            //1.判断是否需要创建该剖面或者只是添加零件标记;
            CMrSection mrSameSection = null;

            View.ViewAttributes viewAttributes = new View.ViewAttributes();
            viewAttributes.LoadAttributes(CCommonPara.mSectionAttPath);

            SectionMarkBase.SectionMarkAttributes sectionMarkAttributes = new SectionMarkBase.SectionMarkAttributes();
            sectionMarkAttributes.LoadAttributes(CCommonPara.mSectionMarkNotePath);

            View        sectionView = null;
            SectionMark setionMark  = null;

            Point sectionMinYPt = new Point();
            Point sectionMaxYPt = new Point();

            mrSection.GetSectionMinYAndMaxYPoint(ref sectionMinYPt, ref sectionMaxYPt);

            double dblY = 50;

            Point startPt = null;
            Point endPt   = null;

            Point partLeftBottomPt = mrPart.mLeftBottomPoint;
            Point partLeftTopPt    = mrPart.mLeftTopPoint;

            //2.如果Y值最大的点在顶部梁的上方;
            if (CDimTools.GetInstance().IsThePointOnLine(sectionMaxYPt, tBLeftTopPt, tBRightTopPt) > 0)
            {
                Point newMaxYPt = new Point(sectionMaxYPt.X, sectionMaxYPt.Y + dblY, 0);
                Point footPt    = CDimTools.GetInstance().ComputeFootPointToLine(newMaxYPt, partLeftBottomPt, partLeftTopPt);
                startPt = footPt;
            }
            else
            {
                Point footPt    = CDimTools.GetInstance().ComputeFootPointToLine(partLeftTopPt, tBLeftTopPt, tBRightTopPt);
                Point newMaxYPt = new Point(footPt.X, footPt.Y + dblY, 0);
                footPt  = CDimTools.GetInstance().ComputeFootPointToLine(newMaxYPt, partLeftBottomPt, partLeftTopPt);
                startPt = footPt;
            }

            //3.如果Y值最小的点在底部梁的下方;
            if (CDimTools.GetInstance().IsThePointOnLine(sectionMinYPt, bBLeftTopPt, bBRightTopPt) < 0)
            {
                Point newMinYPt = new Point(sectionMinYPt.X, sectionMinYPt.Y - dblY, 0);
                Point footPt    = CDimTools.GetInstance().ComputeFootPointToLine(newMinYPt, partLeftBottomPt, partLeftTopPt);
                endPt = footPt;
            }
            else
            {
                Point footPt    = CDimTools.GetInstance().ComputeFootPointToLine(partLeftBottomPt, bBLeftTopPt, bBRightTopPt);
                Point newMinYPt = new Point(footPt.X, footPt.Y - dblY, 0);
                footPt = CDimTools.GetInstance().ComputeFootPointToLine(newMinYPt, partLeftBottomPt, partLeftTopPt);
                endPt  = footPt;
            }

            if (CCommonPara.mHorizontalSection == MrSectionOrientation.MrSectionRight)
            {
                Point tempPt = startPt;
                startPt = endPt;
                endPt   = startPt;
            }

            bool bNeedCreateView = IsTheSectionNeedCreateView(mrSection, ref mrSameSection);

            if (bNeedCreateView)
            {
                mSectionMarkIndex++;
                mrSection.mSectionMark = mSectionMarkArray[mSectionMarkIndex];
                View.CreateSectionView(mFrontView, startPt, endPt, new Point(0, 0, 0), CCommonPara.mDblSectionUpDepth
                                       , CCommonPara.mDblSectionDownDepth, viewAttributes, sectionMarkAttributes, out sectionView, out setionMark);
            }
            else if (CCommonPara.mbShowSameSectionMark)
            {
                sectionMarkAttributes.MarkName = mrSameSection.mSectionMark;
                setionMark = new SectionMark(mFrontView, startPt, endPt, sectionMarkAttributes);
                setionMark.Insert();
                mFrontView.Modify();
            }
        }
示例#4
0
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            try
            {
                TSM.Model          model          = new TSM.Model();
                TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler();
                TSG.Vector         UpDirection    = new TSG.Vector(0.0, 0.0, 1.0);
                TSD.Size           A3             = new TSD.Size(410, 287);

                TSM.TransformationPlane current = model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane());

                TSM.ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects();
                while (modelObjectEnum.MoveNext())
                {
                    if (modelObjectEnum.Current is Tekla.Structures.Model.Part)
                    {
                        TSM.Part selectedPart = (TSM.Part)modelObjectEnum.Current;

                        string USER_FIELD_3 = "", USER_FIELD_4 = "";
                        selectedPart.GetUserProperty("USER_FIELD_3", ref USER_FIELD_3);
                        selectedPart.GetUserProperty("USER_FIELD_4", ref USER_FIELD_4);
                        USER_FIELD_4 = USER_FIELD_4.Replace("(?)", "");
                        selectedPart.SetUserProperty("USER_FIELD_4", USER_FIELD_4);

                        if (USER_FIELD_3 == "M")
                        {
                            TSD.Drawing gaDrawing = new TSD.GADrawing("BRAD-Mod-Ass", A3);
                            gaDrawing.Name   = selectedPart.Name;
                            gaDrawing.Title1 = "SITEWORK";
                            gaDrawing.Title2 = USER_FIELD_3 + USER_FIELD_4;
                            gaDrawing.Title3 = "";
                            gaDrawing.Insert();
                            drawingHandler.SetActiveDrawing(gaDrawing, false);

                            model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new Tekla.Structures.Model.TransformationPlane(selectedPart.GetCoordinateSystem()));
                            TSM.Solid tsolid  = selectedPart.GetSolid();
                            TSG.Point tsMinPt = tsolid.MinimumPoint;
                            TSG.Point tsMaxPt = tsolid.MaximumPoint;
                            model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new Tekla.Structures.Model.TransformationPlane());

                            if (selectedPart.Name.Contains("BEAM"))
                            {
                                TSG.CoordinateSystem ModelObjectCoordSys = selectedPart.GetCoordinateSystem();
                                TSG.CoordinateSystem PlanViewCoordSys    = new TSG.CoordinateSystem();
                                PlanViewCoordSys.Origin = new TSG.Point(ModelObjectCoordSys.Origin);
                                PlanViewCoordSys.AxisX  = new TSG.Vector(ModelObjectCoordSys.AxisX) * -1.0;
                                PlanViewCoordSys.AxisY  = new TSG.Vector(ModelObjectCoordSys.AxisY);

                                TSG.Vector tempVector = (PlanViewCoordSys.AxisX.Cross(UpDirection));
                                if (tempVector == new TSG.Vector())
                                {
                                    tempVector = (ModelObjectCoordSys.AxisY.Cross(UpDirection));
                                }

                                PlanViewCoordSys.AxisX = tempVector.Cross(UpDirection);
                                PlanViewCoordSys.AxisY = tempVector;

                                TSM.Solid solid = selectedPart.GetSolid();

                                TSG.AABB aabbPlanView = new TSG.AABB();
                                aabbPlanView.MinPoint = new TSG.Point(-50, tsMinPt.Z - 50, tsMinPt.Y - 50);
                                aabbPlanView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Z + 50, tsMaxPt.Y + 50);

                                TSD.View PlanView = new TSD.View(gaDrawing.GetSheet(), PlanViewCoordSys, PlanViewCoordSys, aabbPlanView, "BRAD-Mod-Ass");
                                PlanView.Name  = "TOP";
                                PlanView.Scale = 10;
                                PlanView.Attributes.Shortening.CutParts      = true;
                                PlanView.Attributes.Shortening.MinimumLength = 1200;
                                PlanView.Attributes.Shortening.Offset        = 0.5;
                                PlanView.Insert();
                                PlanView.Attributes.FixedViewPlacing = true;
                                PlanView.Origin = new TSG.Point(100, 200);
                                PlanView.Modify();

                                TSG.CoordinateSystem FrontViewCoordSys = (TSG.CoordinateSystem)PlanViewCoordSys;
                                FrontViewCoordSys.AxisX = tempVector.Cross(UpDirection).GetNormal();
                                FrontViewCoordSys.AxisY = UpDirection.GetNormal();

                                TSG.AABB aabbFrontView = new TSG.AABB();
                                aabbFrontView.MinPoint = new TSG.Point(-50, tsMinPt.Y - 50, tsMinPt.Z - 50);
                                aabbFrontView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Y + 50, tsMaxPt.Z + 50);

                                TSD.View FrontView = new TSD.View(gaDrawing.GetSheet(), FrontViewCoordSys, FrontViewCoordSys, aabbFrontView, "BRAD-Mod-Ass");
                                FrontView.Name  = "FRONT";
                                FrontView.Scale = 10;
                                FrontView.Attributes.Shortening.CutParts      = true;
                                FrontView.Attributes.Shortening.MinimumLength = 1200;
                                FrontView.Attributes.Shortening.Offset        = 0.5;
                                FrontView.Insert();
                                FrontView.Attributes.FixedViewPlacing = true;
                                FrontView.Origin = new TSG.Point(100, (200 - FrontView.Height - 2));
                                FrontView.Modify();
                            }
                            if (selectedPart.Name.Contains("COLUMN"))
                            {
                                TSG.CoordinateSystem ModelObjectCoordSys = selectedPart.GetCoordinateSystem();
                                TSG.CoordinateSystem PlanViewCoordSys    = new TSG.CoordinateSystem();
                                PlanViewCoordSys.Origin = new TSG.Point(ModelObjectCoordSys.Origin);
                                PlanViewCoordSys.AxisX  = new TSG.Vector(ModelObjectCoordSys.AxisX);
                                PlanViewCoordSys.AxisY  = new TSG.Vector(ModelObjectCoordSys.AxisY);

                                TSG.Vector tempVector = (PlanViewCoordSys.AxisX.Cross(UpDirection));
                                if (tempVector == new TSG.Vector())
                                {
                                    tempVector = (ModelObjectCoordSys.AxisY.Cross(UpDirection));
                                }

                                TSG.AABB aabbPlanView = new TSG.AABB();
                                aabbPlanView.MinPoint = new TSG.Point(-50, tsMinPt.Y - 50, tsMinPt.Z - 50);
                                aabbPlanView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Y + 50, tsMaxPt.Z + 50);

                                TSD.View PlanView = new TSD.View(gaDrawing.GetSheet(), PlanViewCoordSys, PlanViewCoordSys, aabbPlanView, "BRAD-Mod-Ass");
                                PlanView.Name  = "TOP";
                                PlanView.Scale = 10;
                                PlanView.Attributes.Shortening.CutParts      = true;
                                PlanView.Attributes.Shortening.MinimumLength = 1200;
                                PlanView.Attributes.Shortening.Offset        = 0.5;
                                PlanView.Origin = new TSG.Point(100, 200);
                                PlanView.Insert();
                                PlanView.Attributes.FixedViewPlacing = true;
                                PlanView.Modify();

                                TSG.CoordinateSystem FrontViewCoordSys = (TSG.CoordinateSystem)PlanViewCoordSys;
                                FrontViewCoordSys.AxisY = new TSG.Vector(ModelObjectCoordSys.AxisY).Cross(UpDirection) * -1;

                                TSG.AABB aabbFrontView = new TSG.AABB();
                                aabbFrontView.MinPoint = new TSG.Point(-50, tsMinPt.Z - 50, tsMinPt.Y - 50);
                                aabbFrontView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Z + 50, tsMaxPt.Y + 50);

                                TSD.View FrontView = new TSD.View(gaDrawing.GetSheet(), FrontViewCoordSys, FrontViewCoordSys, aabbFrontView, "BRAD-Mod-Ass");
                                FrontView.Name  = "FRONT";
                                FrontView.Scale = 10;
                                FrontView.Attributes.Shortening.CutParts      = true;
                                FrontView.Attributes.Shortening.MinimumLength = 1200;
                                FrontView.Attributes.Shortening.Offset        = 0.5;
                                FrontView.Origin = new TSG.Point(100, (200 - FrontView.Height - 30));
                                FrontView.Insert();
                                FrontView.Attributes.FixedViewPlacing = true;
                                FrontView.Modify();
                            }
                            drawingHandler.CloseActiveDrawing(true);
                        }
                    }
                }
                MessageBox.Show("Drawings Created");
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current);
            }
            catch { }
        }
        /// <summary>
        /// 创建所有零部件的剖面;
        /// </summary>
        private void CreateAllPartSection()
        {
            CDimTools.GetInstance().SortMrPartByMinX(mAllSectionPartList);

            foreach (CMrPart mrPart in mAllSectionPartList)
            {
                //1.如果零部件已经存在于剖面中则直接返回;
                if (IsPartInSection(mrPart))
                {
                    continue;
                }

                CMrSection mrSection = new CMrSection(MrSectionType.MrSectionBeam);
                mrSection.AppendSectionPart(mrPart);

                Point minXPt = mrPart.GetMinXPoint();
                Point maxXpt = mrPart.GetMaxXPoint();

                mrSection.mSectionMidX = (minXPt.X + maxXpt.X) / 2.0;

                //2.把所有属于该剖面的零部件加入;
                AddPartInSection(mrSection);

                mSectionList.Add(mrSection);

                //3.判断是否需要创建该剖面或者只是添加零件标记;
                CMrSection mrSameSection = null;

                View.ViewAttributes viewAttributes = new View.ViewAttributes();
                viewAttributes.LoadAttributes(CCommonPara.mSectionAttPath);

                SectionMarkBase.SectionMarkAttributes sectionMarkAttributes = new SectionMarkBase.SectionMarkAttributes();
                sectionMarkAttributes.LoadAttributes(CCommonPara.mSectionMarkNotePath);

                View        sectionView = null;
                SectionMark setionMark  = null;

                double mainBeamMaxY = CMrMainBeam.GetInstance().GetMaxYPoint().Y;
                double mainBeamMinY = CMrMainBeam.GetInstance().GetMinYPoint().Y;
                double dblY         = 50;

                double sectionMinY = 0.0;
                double sectionMaxY = 0.0;

                mrSection.GetSectionMinYAndMaxY(ref sectionMinY, ref sectionMaxY);

                Point startPt = null;
                Point endPt   = null;

                if (sectionMinY > mainBeamMinY)
                {
                    sectionMinY = mainBeamMinY;
                }
                if (sectionMaxY < mainBeamMaxY)
                {
                    sectionMaxY = mainBeamMaxY;
                }
                startPt = new Point(mrSection.mSectionMidX, sectionMaxY + dblY, 0);
                endPt   = new Point(mrSection.mSectionMidX, sectionMinY - dblY, 0);

                if (CCommonPara.mHorizontalSection == MrSectionOrientation.MrSectionLeft)
                {
                    Point tempPt = startPt;
                    startPt = endPt;
                    endPt   = tempPt;
                }
                bool bNeedCreateView = IsTheSectionNeedCreateView(mrSection, ref mrSameSection);

                if (bNeedCreateView)
                {
                    mSectionMarkIndex++;
                    mrSection.mSectionMark = mSectionMarkArray[mSectionMarkIndex];

                    View.CreateSectionView(mFrontView, startPt, endPt, new Point(0, 0, 0), CCommonPara.mDblSectionUpDepth
                                           , CCommonPara.mDblSectionDownDepth, viewAttributes, sectionMarkAttributes, out sectionView, out setionMark);
                }
                else if (CCommonPara.mbShowSameSectionMark)
                {
                    sectionMarkAttributes.MarkName = mrSameSection.mSectionMark;
                    setionMark = new SectionMark(mFrontView, startPt, endPt, sectionMarkAttributes);
                    setionMark.Insert();
                    mFrontView.Modify();
                }
            }
        }