C# Macro for Revit - New Caledonia

 

 

  

VB.NET version

 

funzionante esclusivamente in famiglie di masse concettuali

 

using System;
using Autodesk.Revit;
using Autodesk.Revit.Geometry;
using Autodesk.Revit.Creation;
using Autodesk.Revit.Elements;
using System.Collections;
using Autodesk.Revit.Symbols;
using Autodesk.Revit.Structural.Enums;

 

 

 // crea una geometria arco
            XYZ end0 = Application.Create.NewXYZ(0, -1, 0);
            XYZ end1 = Application.Create.NewXYZ(0, 1, 0);
            XYZ pointOnCurve = Application.Create.NewXYZ(1, 0, 0);

            Arc geomArc = Application.Create.NewArc(end0, end1, pointOnCurve);

            // crea una geometria piano
            XYZ origin = Application.Create.NewXYZ(0, 0, 0);
            XYZ normal = Application.Create.NewXYZ(1, 0, 0);
            Plane geomPlane = Application.Create.NewPlane(normal, origin);

            // crea un piano sketch
            SketchPlane sketch = FamilyCreate.NewSketchPlane(geomPlane);

            // crea un elemento ModelArc usando la geometria arco e il piano sketch creati
            ModelArc arc = FamilyCreate.NewModelCurve(geomArc, sketch) as ModelArc;

            CurveElement curve = arc;

            Reference curveRef = curve.GeometryCurve.Reference;

            double n = 1.00;
            double i;

            for (i = 0.05; i <= n-0.05 ; i = i + 0.05)
            {
               
                PointOnEdge pointRef = Application.Create.NewPointOnEdge(curveRef, i);
                ReferencePoint referencepoint = Document.FamilyCreate.NewReferencePoint(pointRef);

          

            string fileName = @"C:\Stefano\nuovacaledonia\pipes.rfa";

           
               
            //prova a caricare la famiglia

            FamilySymbol family = null;

            string list = "unicotipo";

            if (!Document.LoadFamilySymbol(fileName, list, out family))
            {
                throw new Exception("Unable to load " + fileName);
            }

            XYZ location = referencepoint.Position;

            XYZ direction = Application.Create.NewXYZ(location);

                FamilyInstance unico = FamilyCreate.NewFamilyInstance(location, family, direction, referencepoint,  StructuralType.NonStructural);

                Parameter altezza = unico.get_Parameter("altezza_gusci");

              
               
                // costrutto if() else
               
               if (i<0.5)
               
                altezza.Set(1.5+i*5);

               else

                    altezza.Set(6.5 - i*5);

AllegatoDimensione
Binary Data pipes.rfa216 KB