Modelo analítico contextual na API do Revit

Explore a API recém-desenvolvida no contexto de modelagem analítica.

Este projeto faz parte de uma iniciativa mais ampla de Analytical Driven Modeling (Modelagem orientada por análise) para o Revit, que introduz uma abordagem inovadora para a modelagem analítica, aprimorando os recursos gerais de modelagem estrutural. O modelo analítico é uma parte essencial dos dados de BIM e está sujeito aos fluxos de trabalho colaborativos entre equipes de engenharia e equipes de projeto; portanto, o Revit, com o novo conjunto de recursos e comportamentos, permitirá que os engenheiros:

Elementos do Revit com uma nova API

Novas classes de API

AnalyticalElement – representa a classe base para todos os objetos analíticos. Substituiu AnalyticalModel.

AnalyticalMember – representa um elemento linear no modelo analítico estrutural. Substituiu AnalyticalModelStick e AnalyticalModelColumn.

AnalyticalPanel – representa uma superfície no modelo analítico estrutural. Substituiu AnalyticalModelSurface.
  • AnalyticalPanel Create(Document aDoc, CurveLoop curveLoop) - Method which creates a new instance of an Analytical Panel within the project.
  • CurveLoop GetOuterContour() - Returns the Curve Loop that defines the geometry of the Analytical Surface element.
  • bool IsCurveLoopValid(CurveLoop profile) - Checks if curve loop is valid for Analytical Panel.
    • Para modificar a geometria do painel analítico, os usuários devem usar a estrutura SketchEditScope. Isso foi aprimorado com um novo método:
      •  void StartWithNewSketch(ElementId elementId) - Starts a sketch edit mode for an element which, at this moment, doesn't have a sketch.
    • Outra forma de editar a geometria é:
      • void SetOuterContour(CurveLoop outerContour) - Sets the Curve Loop that defines the geometry of the Analytical Surface element.


      • Como para AnalyticalMember, a definição do contorno para o painel analítico quebrará a conexão com outros elementos analíticos. Se o usuário desejar mover o canto e manter a conexão, existem outras maneiras de obter isso, como ElementTransformUtils.moveElements.

  •  ISet<ElementId> GetAnalyticalOpeningsIds() - Returns the Analytical Openings Ids of the Analytical Panel.
  • ElementId SketchId - Sketch associated to this Revit element.
    
  • AnalyticalStructuralRole StructuralRole - Structural role assigned to the Analytical Panel.
AnalyticalOpening – um elemento que representa uma abertura em um painel analítico. Esse é um novo objeto na API do Revit (antes desta versão, não havia nenhum elemento separado para aberturas analíticas).
  • AnalyticalOpening Create(Document doc, CurveLoop curveLoop, ElementId panelId) - Method which creates a new instance of an Analytical Opening within the project.
  • CurveLoop GetOuterContour () - Returns the Curve Loop that defines the geometry of the Analytical Surface element.
    
  •  bool IsCurveLoopValidForAnalyticalOpening(CurveLoop loop, Document aDoc, ElementId panelId) - Checks if curve loop is valid for Analytical Opening.
    • Para modificar a geometria de aberturas analíticas, use a estrutura SketchEditScope.
    • Outra forma de modificar a geometria de aberturas analíticas é:
      •  void SetOuterContour(CurveLoop outerContour) - Sets the Curve Loop that defines the geometry of the Analytical Surface element.
  • ElementId PanelId - ElementId of the host Analytical Panel.
    
  •  ElementId SketchId - Sketch associated to this Revit element.

AnalyticalToPhysicalAssociationManager – gerencia as associações entre os elementos analíticos e físicos. Anteriormente, os próprios elementos sabiam sobre os demais e o usuário não tinha controle sobre eles (não era possível modificar a associação). Com essa nova abordagem, é possível editar a associação. A associação 1 para 1 é suportada e os elementos não podem fazer parte de várias associações ao mesmo tempo.

AnalyticalNodeData – contém informações sobre o status da conexão dos nós analíticos.
  • AnalyticalNodeData GetAnalyticalNodeData ( Element element) - Returns AnalyticalNodeData associated with this element, if it exists.
    
  • AnalyticalNodeConnectionStatus GetConnectionStatus () - Returns the Connections Status for an
    Analytical Node.

AnalyticalLinks, BoundaryConditions e Loads foram migrados para trabalhar com os novos elementos. A API relacionada a eles permanece, na maioria dos casos, a mesma. Foram feitos alguns aprimoramentos para Loads.

Cargas
  •  LineLoad.Create(Document aDoc,ElementId hostElemId, XYZ forceVector1, XYZmomentVector1, LineLoadType symbol).
  •  LineLoad.Create(Document aDoc,ElementId hostElemId, int curveIndex, XYZ forceVector1, XYZ momentVector1, Structure.LineLoadType symbol).
  •  LineLoad.IsValidHostId(Document doc, ElementId hostElemId).
  •  AreaLoad.IsValidHostId(Document doc, ElementId hostElemId).
  •  AreaLoad.Create(Document doc, ElementId hostElemId, XYZ forceVector1, AreaLoadType symbol).
  •  PointLoad.Create(Document doc, ElementId hostElemId, AnalyticalElementSelector selector, XYZ forceVector, XYZ momentVector, AreaLoadTyp 
    symbol).
  • PointLoad.IsValidHostId(Document doc, ElementId hostElemId).

Amostras

Criação de um membro analítico

      using (Transaction transaction = new Transaction(document, "Create Analytical Member"))
               {
                  transaction.Start();
                  //create curve which will be assigned to the analytical member
                  Line line = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(5, 0, 0));
                  //create the AnalyticalMember
                  AnalyticalMember analyticalMember = AnalyticalMember.Create(document, line);
                  analyticalMember.StructuralRole = AnalyticalStructuralRole.StructuralRoleBeam;
                  transaction.Commit();
                }

Criação de um painel analítico

 using (Transaction transaction = new Transaction(revitDoc, "Create Analytical Panel"))
         {
            transaction.Start();
            //create the curveLoop for the AnalyticalPanel element
            CurveLoop profileloop = new CurveLoop();
            profileloop.Append(Line.CreateBound(new XYZ(1, 1, 0), new XYZ(2, 1, 0)));
            profileloop.Append(Line.CreateBound(new XYZ(2, 1, 0), new XYZ(2, 2, 0)));
            profileloop.Append(Line.CreateBound(new XYZ(2, 2, 0), new XYZ(1, 2, 0)));
            profileloop.Append(Line.CreateBound(new XYZ(1, 2, 0), new XYZ(1, 1, 0)));
            //create the AnalyticalPanel 
            analyticalPanel = AnalyticalPanel .Create(revitDoc, profileloop);
            transaction.Commit();
          }

Adicionar nova associação entre um elemento físico e um elemento analítico

using (Transaction trans = new Transaction(doc, "AddAssociationBetweenPhysicalAndAnalyticalElements"))
 {
            trans.Start();
            ElementId analyticalElementId = ContextualAnalyticalModel.Utilities.GetSelectedObject(activeDoc, "Please select analytical element");
            ElementId physicalElementId = ContextualAnalyticalModel.Utilities.GetSelectedObject(activeDoc, "Please select physical element");
            //gets the AnalyticalToPhysicalAssociationManager for the current document
            AnalyticalToPhysicalAssociationManager analyticalToPhysicalManager = AnalyticalToPhysicalAssociationManager.GetAnalyticalToPhysicalAssociationManager(doc);
            if (analyticalToPhysicalManager == null)
               return Result.Failed;
            //creates a new association between physical and analytical elements
            analyticalToPhysicalManager.AddAssociation(analyticalElementId, physicalElementId);
            trans.Commit();
  }

Editar o limite para um painel analítico usando a estrutura SketchEditScope



             // Start a sketch edit scope
             SketchEditScope sketchEditScope = new SketchEditScope(document, "Replace line with an arc");
               sketchEditScope.StartWithNewSketch(analyticalPanel.Id);
               using (Transaction transaction = new Transaction(document, "Modify sketch"))
               {
                  transaction.Start();
                  //replace a boundary line with an arc
                  Line line = null;
                  Sketch sketch = document.GetElement(analyticalPanel.SketchId) as Sketch;
                  if (sketch != null)
                  {
                     //find first line in the sketch profile
                    …..
                  }
  	              // Create arc
                  XYZ normal = line.Direction.CrossProduct(XYZ.BasisZ).Normalize().Negate();
                  XYZ middle = line.GetEndPoint(0).Add(line.Direction.Multiply(line.Length / 2));
                  Curve arc = Arc.Create(line.GetEndPoint(0), line.GetEndPoint(1), middle.Add(normal.Multiply(20)));
                  // Remove element referenced by the found line. 
                  document.Delete(line.Reference.ElementId);
                  // Model curve creation automatically puts the curve into the sketch, if sketch edit scope is running.
                  document.Create.NewModelCurve(arc, sketch.SketchPlane);
                  transaction.Commit();
               }
               sketchEditScope.Commit(new FailurePreproccessor());

Mover um nó analítico e manter a conexão



            // Create Analytical Panel
            AnalyticalPanel analyticalPanel = CreateAnalyticalPanel.CreateAMPanel(document);
            // Create the connected Analytical Member
            AnalyticalMember analyticalMember = CreateAnalyticalMember.CreateMember(document);
            // Select the node
            Reference eRef = activeDoc.Selection.PickObject(ObjectType.PointOnElement , "Select an Analytical Node");
          
            // Move the Analytical Node using ElementTransformUtils
            using (Transaction transaction = new Transaction(document, "Move node with ElementTransformUtils"))
            {
               transaction.Start();
               ElementTransformUtils.MoveElement(document, eRef.ElementId, new XYZ(-5, -5, 0));
               transaction.Commit();
            }

Obter pontos de contorno da superfície analítica

Com a solução anterior:
    
      private List<XYZ> GetSurfaceContourPoints( Document doc, ElementId elementId )
      {
         	// Create point list, get list of curves from analytical model
         	List<XYZ> contourPoints = new List<XYZ>();
         	AnalyticalModel analyticalModel = (doc.GetElement(elementId) as AnalyticalModel);
         	IList<Curve> curves = analyticalModel.GetCurves(AnalyticalCurveType.RawCurves);
         
         	// Iterate over curves and make the desired processing   
         …...	
        	return contourPoints;
      }
Com a nova solução:
     
      private List<XYZ> GetSurfaceContourPoints( Document doc, ElementId elementId )
      {
         	// Create point list, get list of curves from analytical model
         	List<XYZ> contourPoints = new List<XYZ>();
         	AnalyticalPanel analyticalPanel = (doc.GetElement(elementId) as AnalyticalPanel);
          CurveLoop outerContour = analyticalPanel.GetOuterContour();
         
         	// Iterate over curves and make the desired processing 
          …...	
        	return contourPoints;
      }

Obtém o elemento analítico associado de um elemento físico

     
      AnalyticalElement GetAnalyticalElement(Element physicalElement)
      {
         AnalyticalElement analyticalElement = null;
         Document document = element.Document;
         AnalyticalToPhysicalAssociationManager assocManager = AnalyticalToPhysicalAssociationManager.GetAnalyticalToPhysicalAssociationManager(document);
         if (assocManager != null)
         {
            ElementId associatedElementId = assocManager.GetAssociatedElementId(physicalElement.Id);
            if (associatedElementId != ElementId.InvalidElementId)
            {
               Element associatedElement = document.GetElement(associatedElementId);
               if (associatedElement != null && associatedElement is AnalyticalElement)
               {
                  analyticalElement = associatedElement as AnalyticalElement;
               }
            }
         }
         return analyticalElement;
      }

Criar condições do limite de linha

Com a solução anterior:

       
        private BoundaryConditions CreateLineBC(Element hostElement)
        {
										    Document createDoc = hostElement.Document.Create;
 
             	// use Document.NewLineBoundaryConditions Method
              BoundaryConditions createdBC = 
                    createDoc.NewLineBoundaryConditions(hostElement.GetAnalyticalModel(), 0, 0, 0, 0, 0, 0, 0, 0);
 
            return createdBC;
        }

Com a nova solução:

      private BoundaryConditions CreateLineBC(Element hostElement)
      {
         Document createDoc = hostElement.Document.Create;

         // use Document.NewLineBoundaryConditions Method
         AnalyticalElement analyticalElement = GetAnalyticalElement(hostElement);
         BoundaryConditions createdBC =
                    createDoc.NewLineBoundaryConditions(analyticalElement, 0, 0, 0, 0, 0, 0, 0, 0);
         return createdBC;
      }