예제 #1
0
        Stream(ArrayList data, RebarShapeMultiplanarDefinition rebarShapeDef)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(RebarShapeMultiplanarDefinition)));
            data.Add(new Snoop.Data.Bool("IsDuplicateShapePresent", rebarShapeDef.IsDuplicateShapePresent));
            data.Add(new Snoop.Data.Bool("IsStartConnectorPresent", rebarShapeDef.IsStartConnectorPresent));
            data.Add(new Snoop.Data.Bool("IsEndConnectorPresent", rebarShapeDef.IsEndConnectorPresent));
            data.Add(new Snoop.Data.Double("OutOfPlaneBendDiameter", rebarShapeDef.OutOfPlaneBendDiameter));

            data.Add(new Snoop.Data.ElementId("DepthParamId", rebarShapeDef.DepthParamId, m_activeDoc));
        }
예제 #2
0
        CollectEvent(object sender, CollectorEventArgs e)
        {
            // cast the sender object to the SnoopCollector we are expecting
            Collector snoopCollector = sender as Collector;

            if (snoopCollector == null)
            {
                Debug.Assert(false); // why did someone else send us the message?
                return;
            }


            // see if it is a type we are responsible for
            ElementType sym = e.ObjToSnoop as ElementType;

            if (sym != null)
            {
                Stream(snoopCollector.Data(), sym);
                return;
            }


            RebarShapeDefinition rebarShapeDef = e.ObjToSnoop as RebarShapeDefinition;

            if (rebarShapeDef != null)
            {
                Stream(snoopCollector.Data(), rebarShapeDef);
                return;
            }

            RebarShapeSegment segment = e.ObjToSnoop as RebarShapeSegment;

            if (segment != null)
            {
                Stream(snoopCollector.Data(), segment);
                return;
            }

            RebarShapeConstraint segmentConstraint = e.ObjToSnoop as RebarShapeConstraint;

            if (segmentConstraint != null)
            {
                Stream(snoopCollector.Data(), segmentConstraint);
                return;
            }

            RebarShapeMultiplanarDefinition multiPlanarDef = e.ObjToSnoop as RebarShapeMultiplanarDefinition;

            if (multiPlanarDef != null)
            {
                Stream(snoopCollector.Data(), multiPlanarDef);
                return;
            }
        }
예제 #3
0
        /// <summary>
        /// Create the multi-planar Rebar Shape according to the trapezoid wire-frame.
        /// </summary>
        /// <param name="revitDoc">Revit DB Document</param>
        /// /// <param name="bendDiameter">OutOfPlaneBendDiameter for multi-planar shape</param>
        /// <returns>Created multi-planar Rebar Shape</returns>
        public RebarShape ConstructMultiplanarRebarShape(Document revitDoc, double bendDiameter)
        {
            // Construct a segment definition with 2 lines.
            RebarShapeDefinitionBySegments shapedef = new RebarShapeDefinitionBySegments(revitDoc, 2);

            // Define parameters for the dimension.
            ElementId B  = SharedParameterUtil.GetOrCreateDef("B", revitDoc);
            ElementId H  = SharedParameterUtil.GetOrCreateDef("H", revitDoc);
            ElementId K  = SharedParameterUtil.GetOrCreateDef("K", revitDoc);
            ElementId MM = SharedParameterUtil.GetOrCreateDef("MM", revitDoc);


            // Set parameters default values according to the size Trapezoid shape.
            shapedef.AddParameter(B, Top.Length);
            shapedef.AddParameter(H, Bottom.Length - Top.Length);
            shapedef.AddParameter(K, Vertical.Length);
            shapedef.AddParameter(MM, 15);

            // Rebar shape geometry curves consist of Line S0 and Line S1.
            //
            //
            //         |Y       V1
            //         |--S0(B)--\ 
            //         |          \S1(H, K)
            //         |           \
            //---------|O-----------\----X
            //         |

            // Define Segment 0 (S0)
            //
            // S0's direction is fixed in positive X Axis.
            shapedef.SetSegmentFixedDirection(0, 1, 0);
            // S0's length is determined by parameter B
            shapedef.AddConstraintParallelToSegment(0, B, false, false);

            // Define Segment 1 (S1)
            //
            // Fix S1's direction.
            shapedef.SetSegmentFixedDirection(1, Bottom.Length - Top.Length, -Vertical.Length);
            // S1's length in positive X Axis is parameter H.
            shapedef.AddConstraintToSegment(1, H, 1, 0, 1, false, false);
            // S1's length in negative Y Axis is parameter K.
            shapedef.AddConstraintToSegment(1, K, 0, -1, 1, false, false);

            // Define Vertex 1 (V1)
            //
            // S1 at V1 is turn to right and the angle is acute.
            shapedef.AddBendDefaultRadius(1, RebarShapeVertexTurn.Right, RebarShapeBendAngle.Acute);

            // Check to see if it's full constrained.
            if (!shapedef.Complete)
            {
                throw new Exception("Shape was not completed.");
            }

            // Try to solve it to make sure the shape can be resolved with default parameter value.
            if (!shapedef.CheckDefaultParameterValues(0, 0))
            {
                throw new Exception("Can't resolve rebar shape.");
            }

            // Define multi-planar definition
            RebarShapeMultiplanarDefinition multiPlanarDef = new RebarShapeMultiplanarDefinition(bendDiameter);

            multiPlanarDef.DepthParamId = MM;

            // Realize the Rebar shape with creation static method.
            // The RebarStype is stirrupTie, and it will attach to the top cover.
            RebarShape newshape = RebarShape.Create(revitDoc, shapedef, multiPlanarDef,
                                                    RebarStyle.StirrupTie, StirrupTieAttachmentType.InteriorFace,
                                                    0, RebarHookOrientation.Left, 0, RebarHookOrientation.Left, 0);

            // Give a readable name
            newshape.Name = "API Corbel Multi-Shape " + newshape.Id;

            // Make sure we can see the created shape from the browser.
            IList <Curve> curvesForBrowser = newshape.GetCurvesForBrowser();

            if (curvesForBrowser.Count == 0)
            {
                throw new Exception("The Rebar shape is invisible in browser.");
            }

            return(newshape);
        }
예제 #4
0
파일: CorbelFrame.cs 프로젝트: AMEE/revit
        /// <summary>
        /// Create the multi-planar Rebar Shape according to the trapezoid wire-frame.
        /// </summary>
        /// <param name="revitDoc">Revit DB Document</param>
        /// /// <param name="bendDiameter">OutOfPlaneBendDiameter for multi-planar shape</param>
        /// <returns>Created multi-planar Rebar Shape</returns>
        public RebarShape ConstructMultiplanarRebarShape(Document revitDoc, double bendDiameter)
        {
            // Construct a segment definition with 2 lines.
            RebarShapeDefinitionBySegments shapedef = new RebarShapeDefinitionBySegments(revitDoc, 2);

            // Define parameters for the dimension.
            ElementId B = SharedParameterUtil.GetOrCreateDef("B", revitDoc);
            ElementId H = SharedParameterUtil.GetOrCreateDef("H", revitDoc);
            ElementId K = SharedParameterUtil.GetOrCreateDef("K", revitDoc);
            ElementId MM = SharedParameterUtil.GetOrCreateDef("MM", revitDoc);

            // Set parameters default values according to the size Trapezoid shape.
            shapedef.AddParameter(B, Top.Length);
            shapedef.AddParameter(H, Bottom.Length - Top.Length);
            shapedef.AddParameter(K, Vertical.Length);
            shapedef.AddParameter(MM, 15);

            // Rebar shape geometry curves consist of Line S0 and Line S1.
            //
            //
            //         |Y       V1
            //         |--S0(B)--\
            //         |          \S1(H, K)
            //         |           \
            //---------|O-----------\----X
            //         |

            // Define Segment 0 (S0)
            //
            // S0's direction is fixed in positive X Axis.
            shapedef.SetSegmentFixedDirection(0, 1, 0);
            // S0's length is determined by parameter B
            shapedef.AddConstraintParallelToSegment(0, B, false, false);

            // Define Segment 1 (S1)
            //
            // Fix S1's direction.
            shapedef.SetSegmentFixedDirection(1, Bottom.Length - Top.Length, -Vertical.Length);
            // S1's length in positive X Axis is parameter H.
            shapedef.AddConstraintToSegment(1, H, 1, 0, 1, false, false);
            // S1's length in negative Y Axis is parameter K.
            shapedef.AddConstraintToSegment(1, K, 0, -1, 1, false, false);

            // Define Vertex 1 (V1)
            //
            // S1 at V1 is turn to right and the angle is acute.
            shapedef.AddBendDefaultRadius(1, -1, RebarShapeBendAngle.Acute);

            // Check to see if it's full constrained.
            if (!shapedef.Complete)
            {
                throw new Exception("Shape was not completed.");
            }

            // Try to solve it to make sure the shape can be resolved with default parameter value.
            if (!shapedef.CheckDefaultParameterValues(0, 0))
            {
                throw new Exception("Can't resolve rebar shape.");
            }

            // Define multi-planar definition
            RebarShapeMultiplanarDefinition multiPlanarDef = new RebarShapeMultiplanarDefinition(bendDiameter);
            multiPlanarDef.DepthParamId = MM;

            // Realize the Rebar shape with creation static method.
            // The RebarStype is stirrupTie, and it will attach to the top cover.
            RebarShape newshape = RebarShape.Create(revitDoc, shapedef, multiPlanarDef,
                RebarStyle.StirrupTie, StirrupTieAttachmentType.InteriorFace,
                0, RebarHookOrientation.Left, 0, RebarHookOrientation.Left, 0);

            // Give a readable name
            newshape.Name = "API Corbel Multi-Shape " + newshape.Id;

            // Make sure we can see the created shape from the browser.
            IList<Curve> curvesForBrowser = newshape.GetCurvesForBrowser();
            if (curvesForBrowser.Count == 0)
            {
                throw new Exception("The Rebar shape is invisible in browser.");
            }

            return newshape;
        }
        private void Stream(ArrayList data, RebarShapeMultiplanarDefinition rebarShapeDef)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(RebarShapeMultiplanarDefinition)));
             data.Add(new Snoop.Data.Bool("IsDuplicateShapePresent", rebarShapeDef.IsDuplicateShapePresent));
             data.Add(new Snoop.Data.Bool("IsStartConnectorPresent", rebarShapeDef.IsStartConnectorPresent));
             data.Add(new Snoop.Data.Bool("IsEndConnectorPresent", rebarShapeDef.IsEndConnectorPresent));
             data.Add(new Snoop.Data.Double("OutOfPlaneBendDiameter", rebarShapeDef.OutOfPlaneBendDiameter));

             data.Add(new Snoop.Data.ElementId("DepthParamId", rebarShapeDef.DepthParamId, m_activeDoc));
        }