Esempio n. 1
0
        public override gpAx2 GetPointLocation(int index)
        {
            var transform = Node.Get <TransformationInterpreter>().CurrTransform;

            var ax2 = new gpAx2();

            ax2.Location = Dependency[0].TransformedPoint3D.GpPnt;

            var circleCenter = Dependency[0].TransformedPoint3D.GpPnt;
            var circleAxis   = new gpAx1();

            circleAxis.Location = (Dependency[0].TransformedPoint3D.GpPnt);
            var pointOnCircle = GetPointOnCircle(circleAxis, Dependency[1].Real, transform);
            var radius        = pointOnCircle.Distance(circleCenter);

            var leftArrowVector = new gpVec(circleCenter, pointOnCircle);

            leftArrowVector.Normalize();
            leftArrowVector.Multiply(radius + DistanceToObject);
            var leftArrowLocation = circleCenter.Translated(leftArrowVector);

            var rightArrowVector   = leftArrowVector.Reversed;
            var rightArrowLocation = circleCenter.Translated(rightArrowVector);

            var topArrowVector = new gpVec(leftArrowVector.XYZ);

            topArrowVector.Cross(new gpVec(ax2.Direction));
            topArrowVector.Normalize();
            topArrowVector.Multiply(radius + DistanceToObject);
            var topArrowLocation = circleCenter.Translated(topArrowVector);

            var bottomArrowVector   = topArrowVector.Reversed;
            var bottomArrowLocation = circleCenter.Translated(bottomArrowVector);

            switch (index)
            {
            case 0:
                ax2.Location   = (leftArrowLocation);
                ax2.XDirection = (new gpDir(leftArrowVector));
                return(ax2);

            case 1:
                ax2.Location   = (topArrowLocation);
                ax2.XDirection = (new gpDir(topArrowVector));
                return(ax2);

            case 2:
                ax2.Location   = (rightArrowLocation);
                ax2.XDirection = (new gpDir(rightArrowVector));
                return(ax2);

            case 3:
                ax2.Location   = (bottomArrowLocation);
                ax2.XDirection = (new gpDir(bottomArrowVector));
                return(ax2);

            default:
                return(null);
            }
        }
Esempio n. 2
0
        public override gpAx2 GetPointLocation(int index)
        {
            //var transform = Node.Get<TransformationInterpreter>().CurrTransform;
            var transform  = NodeBuilderUtils.GetGlobalTransformation(new NodeBuilder(NodeBuilderUtils.FindSketchNode(Node)));
            var ax2        = new gpAx2();
            var centerAxis = new gpAx1();

            if (Dependency[0].Name == InterpreterNames.Reference)
            {
                var circleLocation = Dependency[0].RefTransformedPoint3D.GpPnt;
                var pointBuilder   = Dependency[0].ReferenceBuilder;
                var circleNormal   = pointBuilder[0].Reference.Children[1].Get <Axis3DInterpreter>().Axis.Direction;

                centerAxis = new gpAx1(circleLocation, new gpDir(circleNormal.GpPnt.XYZ).Transformed(transform));
                ax2.Axis   = (centerAxis);
            }
            if (Dependency[0].Name == InterpreterNames.Axis3D)
            {
                centerAxis = Dependency[0].TransformedAxis3D;
                ax2.Axis   = (centerAxis);
            }
            var circleCenter  = centerAxis;
            var pointOnCircle = GetPointOnCircle(centerAxis, Dependency[1].Real, transform);
            var radius        = pointOnCircle.Distance(circleCenter.Location);

            var leftArrowVector = new gpVec(circleCenter.Location, pointOnCircle);

            leftArrowVector.Normalize();
            leftArrowVector.Multiply(radius + DistanceToObject);
            var leftArrowLocation = circleCenter.Location.Translated(leftArrowVector);

            var rightArrowVector   = leftArrowVector.Reversed;
            var rightArrowLocation = circleCenter.Location.Translated(rightArrowVector);

            var topArrowVector = new gpVec(leftArrowVector.XYZ);

            topArrowVector.Cross(new gpVec(ax2.Direction));
            topArrowVector.Normalize();
            topArrowVector.Multiply(radius + DistanceToObject);
            var topArrowLocation = circleCenter.Location.Translated(topArrowVector);

            var bottomArrowVector   = topArrowVector.Reversed;
            var bottomArrowLocation = circleCenter.Location.Translated(bottomArrowVector);

            switch (index)
            {
            case 0:
                ax2.Location   = (leftArrowLocation);
                ax2.XDirection = (new gpDir(leftArrowVector));
                return(ax2);

            case 1:
                ax2.Location   = (topArrowLocation);
                ax2.XDirection = (new gpDir(topArrowVector));
                return(ax2);

            case 2:
                ax2.Location   = (rightArrowLocation);
                ax2.XDirection = (new gpDir(rightArrowVector));
                return(ax2);

            case 3:
                ax2.Location   = (bottomArrowLocation);
                ax2.XDirection = (new gpDir(bottomArrowVector));
                return(ax2);

            default:
                return(null);
            }
        }