Exemplo n.º 1
0
        // OnInstanceBegin marks the beginning of a family instance to be exported.
        public RenderNodeAction OnInstanceBegin(
            InstanceNode InInstanceNode             // family instance output node
            )
        {
            Element CurrentFamilySymbol = GetElement(InInstanceNode.GetSymbolId());

            if (CurrentFamilySymbol != null)
            {
                // Keep track of the world transform for the instance being processed.
                WorldTransformStack.Push(WorldTransformStack.Peek().Multiply(InInstanceNode.GetTransform()));

                ElementType CurrentInstanceType = CurrentFamilySymbol as ElementType;

                // Keep track of the instance being processed.
                if (CurrentInstanceType != null)
                {
                    PushInstance(CurrentInstanceType, WorldTransformStack.Peek(), "Instance Begin");
                }
                else
                {
                    CurrentElementSkipped = !PushElement(CurrentFamilySymbol, WorldTransformStack.Peek(), "Symbol Begin");
                }
            }

            // We always wanna proceed, because in certain cases where InInstanceNode is valid but CurrentInstance is not,
            // what follows is valid geometry related to the instance previously exported.
            return(CurrentElementSkipped ? RenderNodeAction.Skip : RenderNodeAction.Proceed);
        }
Exemplo n.º 2
0
        public RenderNodeAction OnInstanceBegin(InstanceNode node)
        {
            Debug.WriteLine("  OnInstanceBegin: " + node.NodeName + " symbol: " + node.GetSymbolId().IntegerValue);
            // This method marks the start of processing a family instance
            _transformationStack.Push(CurrentTransform.Multiply(node.GetTransform()));

            // We can either skip this instance or proceed with rendering it.
            return(RenderNodeAction.Proceed);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This is called when family instances are encountered, before OnElementEnd.
        /// We're using it here to maintain the transform stack for that element's heirarchy.
        /// </summary>
        /// <param name="node"></param>
        public void OnInstanceEnd(InstanceNode node)
        {
            Debug.WriteLine(String.Format("{0}OnInstanceEnd", manager.formatDebugHeirarchy.Substring(0, manager.formatDebugHeirarchy.Count() - 2)));

            ElementId symId   = node.GetSymbolId();
            Element   symElem = _doc.GetElement(symId);

            manager.CloseNode(symElem, true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method marks the start of processing a family instance
        /// https://www.revitapidocs.com/2018/2db35bdb-8d14-a015-9bfb-9283f503edab.htm
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public RenderNodeAction OnInstanceBegin(InstanceNode node)
        {
            // We can get particular information about the family instance and its type if we need to
            ElementId    symbolId  = node.GetSymbolId();
            FamilySymbol famSymbol = doc.GetElement(symbolId) as FamilySymbol;

            // Typically, an export context has to manage a stack of transformation
            // for all nested objects, such as instances, lights, links, etc.
            // A combined transformation needs to be applied to the incoming geometry
            // (providing all geometry is to be flattened in the resultant format.)
            tfStack.Push(tfStack.Peek().Multiply(node.GetTransform()));
            return(RenderNodeAction.Proceed);
        }
Exemplo n.º 5
0
        public RenderNodeAction OnInstanceBegin(InstanceNode node)
        {
            Transform     t  = node.GetTransform();
            MessageBuffer mb = new MessageBuffer();

            mb.add(node.GetSymbolId().IntegerValue);
            mb.add(node.NodeName);
            mb.add(t.BasisX.Multiply(t.Scale));
            mb.add(t.BasisY.Multiply(t.Scale));
            mb.add(t.BasisZ.Multiply(t.Scale));
            mb.add(t.Origin);
            OpenCOVERPlugin.COVER.Instance.sendMessage(mb.buf, OpenCOVERPlugin.COVER.MessageTypes.NewInstance);
            return(RenderNodeAction.Proceed);
        }
Exemplo n.º 6
0
        /// <summary>
        /// This is called when family instances are encountered, after OnElementBegin.
        /// We're using it here to maintain the transform stack for that element's heirarchy.
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public RenderNodeAction OnInstanceBegin(InstanceNode node)
        {
            Debug.WriteLine(String.Format("{0}OnInstanceBegin", manager.formatDebugHeirarchy));

            ElementId symId   = node.GetSymbolId();
            Element   symElem = _doc.GetElement(symId);

            Debug.WriteLine(String.Format("{2}OnInstanceBegin: {0}-{1}", symId, symElem.Name, manager.formatDebugHeirarchy));

            var nodeXform = node.GetTransform();

            manager.OpenNode(symElem, nodeXform.IsIdentity ? null : nodeXform, true);

            return(RenderNodeAction.Proceed);
        }
        /// <summary>
        ///     This method marks the beginning of a family instance to be exported.
        /// </summary>
        /// <param name="node">The instance node.</param>
        /// <returns></returns>
        public RenderNodeAction OnInstanceBegin(InstanceNode node)
        {
            try
            {
                Debug.WriteLine("  OnInstanceBegin: " + node.NodeName
                                + " symbol: " + node.GetSymbolId().IntegerValue);

                // This method marks the start of processing a family instance
                transformations.Push(transformations.Peek().Multiply(
                                         node.GetTransform()));
            }
            catch (Exception ex)
            {
                ProcessException(ex);
                return(RenderNodeAction.Skip);
            }

            return(RenderNodeAction.Proceed);
        }
Exemplo n.º 8
0
        public RenderNodeAction OnInstanceBegin(
            InstanceNode node)
        {
            FamilySymbol symbol = _doc.GetElement(
                node.GetSymbolId()) as FamilySymbol;

            Debug.Assert(null != symbol,
                         "expected valid family symbol");

            Debug.Print("InstanceBegin "
                        + symbol.Category.Name + " : "
                        + symbol.Family.Name + " : "
                        + symbol.Name);

            _transformationStack.Push(CurrentTransform
                                      .Multiply(node.GetTransform()));

            return(RenderNodeAction.Proceed);
        }
Exemplo n.º 9
0
        // OnInstanceEnd marks the end of a family instance being exported.
        // This method is invoked even for family instances that were skipped.
        public void OnInstanceEnd(
            InstanceNode InInstanceNode             // family instance output node
            )
        {
            Element CurrentFamilySymbol = GetElement(InInstanceNode.GetSymbolId());

            if (CurrentFamilySymbol != null)
            {
                // Forget the current instance being exported.
                if (CurrentFamilySymbol as ElementType != null)
                {
                    PopInstance("Instance End");
                }
                else
                {
                    PopElement("Symbol End");
                }

                // Forget the current world transform.
                WorldTransformStack.Pop();
            }
        }
Exemplo n.º 10
0
        public RenderNodeAction OnInstanceBegin(InstanceNode node)
        {
            Transform t = node.GetTransform();
            MessageBuffer mb = new MessageBuffer();

            mb.add(node.GetSymbolId().IntegerValue);
            mb.add(node.NodeName);
            mb.add(t.BasisX.Multiply(t.Scale));
            mb.add(t.BasisY.Multiply(t.Scale));
            mb.add(t.BasisZ.Multiply(t.Scale));
            mb.add(t.Origin);
            OpenCOVERPlugin.COVER.Instance.sendMessage(mb.buf, OpenCOVERPlugin.COVER.MessageTypes.NewInstance);
            return RenderNodeAction.Proceed;
        }