Esempio n. 1
0
        void dimensionV(double value, string text = "")
        {
            DisplayDimension dispDim = Model.AddVerticalDimension2(0, 10 * mm, 10 * mm);

            string name = dispDim.GetNameForSelection();

            dispDim.CenterText = true;

            Dimension Dim = Dimensions[iDimensions++] = Model.Parameter(name);

            if (text != "")
            {
                Dim.Name = text;
            }
            Dim.SystemValue = value * mm;
        }
Esempio n. 2
0
        public double[] GetDimensionLineDirect(ModelDoc2 swModel, double[] boundBox, bool vertic,BlockPosition side, out double d, out Annotation annotation,out bool? blockSize,out Ordinate vertex,out Ordinate vertexS,  double[] dsDim,double[] deDim,double[] endDim,string dsName,string deName)
        {
            blockSize = null;
            var swDrawing = (DrawingDoc) swModel;
            var drView = swDrawing.IActiveDrawingView;
            var scale = (double[]) drView.ScaleRatio;
            double vScaleRat = scale[1];
            double[] doubles = null;
            d = 0;
            annotation = null;

            vertex = GetVertexFromBlock(swModel, drView, vScaleRat,true);
            if(!(vertex!=null && SelectVertexDatum(swModel, vertex)))
                vertex = SelectVertexDatumUp(swModel, boundBox, side);

            if (dsDim != null && deDim != null)
            {
                vertexS = GetVertexFromBlock(swModel, drView, vScaleRat, false);
                //swModel.ClearSelection2(true);

                swDrawing.ActivateView(drView.Name);
                bool tmp = swModel.Extension.SelectByID2(@"Точка вставки/" + dsName, "SKETCHPOINT", 0, 0, 0, false, 0, null, 0);
                tmp = swModel.Extension.SelectByID2(@"Точка вставки/" + deName, "SKETCHPOINT", 0, 0, 0, true, 0, null, 0);
                DisplayDimension dim1;
                if (vertic)
                     dim1 = swModel.AddVerticalDimension2(0, 0, 0);
                else
                     dim1 = swModel.AddHorizontalDimension2(0, 0, 0);

                dim1.GetDimension().DrivenState = (int)swDimensionDrivenState_e.swDimensionDriven;
                d = dim1.GetDimension().Value;
                if (vertic)
                {
                    doubles = new double[3] { 1, 0, 0 };
                }
                else
                {
                    doubles = new double[3] {0, 1, 0};
                }
                annotation = dim1.GetAnnotation();
            }
            else
            {

                if (vertic)
                {
                    vertexS = GetVertexFromBlock(swModel, drView, vScaleRat, false);
                    if (!(vertexS != null && SelectVertexDatum(swModel, vertexS)))
                        SelectVertexDatumDown(swModel, boundBox, side);
                    else if (vertex != null)
                        blockSize = vertex.X < vertexS.X;

                    DisplayDimension dim = null;

                    dim = swModel.IAddVerticalDimension2(0, 0, 0);

                    if (dim != null)
                    {
                        d = dim.IGetDimension().Value;
                        doubles = (double[]) dim.IGetDimension().DimensionLineDirection.ArrayData;
                        if (blockSize != null)
                        {
                            vertexS.Y = vertexS.Y + (d/1000)/vScaleRat;
                        }

                        annotation = dim.IGetAnnotation();
                    }
                }
                else
                {
                    vertexS = GetVertexFromBlock(swModel, drView, vScaleRat, false);
                    if (!(vertexS != null && SelectVertexDatum(swModel, vertexS)))
                    {
                        vertexS = SelectVertexDatumUp(swModel, boundBox, side.Not());
                    }
                    else if (vertex != null)
                        blockSize = vertex.X < vertexS.X;

                    var dim = swModel.AddHorizontalDimension2(0, 0, 0);

                    if (dim != null)
                    {
                        d = dim.GetDimension().Value;
                        doubles = (double[]) dim.GetDimension().DimensionLineDirection.ArrayData;
                        annotation = dim.GetAnnotation();

                    }
                }
            }
            swModel.ClearSelection();
            return doubles;
        }