ZeroTouchNodes, how to beginn?

For ZeroTouch node development, I also suggest starting with a lowball glass with your favorite kind of bourbon in it.

5 Likes

Make it a double.

3 Likes

Hi, Mr. Andreas, I tried this apm the zero touch node, in your research you were with VisualStudio or Visual Studio Code (on this one you know how to import classes from the revit API)


My error most certainly comes from the .Net used (7.0) or other

Thanks,
cordially
christian.stan

1 Like

I saw many users want to learn to become a developer, but they’re never learning how to go step by step as an engineer of software development :slightly_smiling_face: . I also have many mistake before jump to develop something :

  • Let’s learn basic of language, how it works, data type. Data structural, how to start a program.
  • Let’s learn how IDE work and which software to work with.
  • Read documentation before start
  • Look to example of another people in GitHub or open source
  • Get start with …
  • Get problem and resolve it
  • Design pattern, clear code, … technical debt,
  • Keep going.

I hope it will be useful

7 Likes

@chuongmep ,

thats right i read books (because i am old) … to understand prinzipels like math, logic and different languages(C++, Python, C#, java) because i finde in Revit, Dynamo, DesignScript and PyRevit all kinds of vocabulary.

I will follow your steps.

KR

Andreas

2 Likes

Hello, you also had this kind of result,
C# is definitely complex

using System;
using Autodesk.Revit.DB;

namespace Custom_Node_essai
{
    public class SimpleFonction
    {
        public static double Multiply_By_n(double inputNumber, double n)
        {
            return inputNumber * n;
        }
        public static double Puissance_n(double Puiss, double n)
        {
            return Math.Pow(Puiss, n);
        }
        public Wall CreateWallUsingCurve2(Autodesk.Revit.DB.Document document, Level level, WallType wallType)
        {
            // Build a location line for the wall creation
            XYZ start = new XYZ(0, 0, 0);
            XYZ end = new XYZ(10, 10, 0);
            Line geomLine = Line.CreateBound(start, end);

            // Determine the other parameters
            double height = 15;
            double offset = 3;

            // Create a wall using the location line and wall type
            return Wall.Create(document, geomLine, wallType.Id, level.Id, height, offset, true, true);
        }
    }

cordially
christian.stan

1 Like

Let try with

using Revit.Elements;
using RevitServices.Transactions;
using Autodesk.Revit.DB;

namespace Custom_Node_essai
{
    public class SimpleFunction
    {
        private SimpleFunction()
        {

        }

        public static double Multiply_By_n(double inputNumber, double n)
        {
            return inputNumber * n;
        }

        public static double Puissance_n(double Puiss, double n)
        {
            return Math.Pow(Puiss, n);
        }

        public static Revit.Elements.Element CreateWallUsingCurve(Autodesk.Revit.DB.Document document, Level level,
            WallType wallType)
        {
            // Build a location line for the wall creation
            XYZ start = new XYZ(0, 0, 0);
            XYZ end = new XYZ(10, 10, 0);
            Line geomLine = Line.CreateBound(start, end);

            // Determine the other parameters
            double height = 15;
            double offset = 3;

            // Create a wall using the location line and wall type
            TransactionManager.Instance.EnsureInTransaction(document);
            Wall wall = Wall.Create(document, geomLine, wallType.Id, level.Id, height, offset, true, true);
            TransactionManager.Instance.TransactionTaskDone();
            return wall.ToDSType(true);
        }
    }
}
2 Likes

Hi @christian.stan

you forgot some conversions (unwrap and wrap elements like python)


using System;
using System.Reflection;
using Autodesk.Revit.DB;
using Dynamo.Graph.Nodes;
using Revit.Elements;
using Revit.GeometryConversion;
using RevitServices.Persistence;
using RevitServices.Transactions;

namespace Custom.Element
{
    public  class SimpleFonction
    {
        private SimpleFonction()
        {
        }
        public static double Multiply_By_n(double inputNumber, double n)
        {
            return inputNumber * n;
        }
        public static double Puissance_n(double Puiss, double n)
        {
            return Math.Pow(Puiss, n);
        }
        public static Revit.Elements.Element CreateWallUsingCurve(Revit.Application.Document dynDocument, Revit.Elements.Element level, Revit.Elements.Element wallType)
        {

            // Build a location line for the wall creation
            XYZ start = new XYZ(0, 0, 0);
            XYZ end = new XYZ(10, 10, 0);
            Line geomLine = Line.CreateBound(start, end);

            // Determine the other parameters
            double height = 15;
            double offset = 3;

            // Convert DynamoDocument to DB.Document 
            var property = dynDocument.GetType().GetProperty("InternalDocument", BindingFlags.NonPublic | BindingFlags.Instance);
            Autodesk.Revit.DB.Document rvt_doc = (Autodesk.Revit.DB.Document)property.GetValue(dynDocument);
            // Other Way
            Autodesk.Revit.DB.Document rvt_doc2 = (Autodesk.Revit.DB.Document)dynDocument.GetType().InvokeMember("InternalDocument", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance, null, dynDocument, null);
            // Other Way without Parammeter Input
            Autodesk.Revit.DB.Document rvt_doc3 = wallType.InternalElement.Document;
            // Other Way without Parammeter Input
            Autodesk.Revit.DB.Document rvt_doc4 = DocumentManager.Instance.CurrentDBDocument;
            // Create a wall using the location line and wall type
            TransactionManager.Instance.EnsureInTransaction(rvt_doc);
            Autodesk.Revit.DB.Wall wall = Autodesk.Revit.DB.Wall.Create(rvt_doc2, geomLine, wallType.InternalElement.Id, level.InternalElement.Id, height, offset, true, true);
            TransactionManager.Instance.TransactionTaskDone();
            return wall.ToDSType(false);

        }
    }
}
2 Likes

Hello, Thank you both Mr. Chuong and Poupin

I was unable to import the Dynamo.Graph.Nodes reference

it works but i have a message displayed during the build

Message
The generation operation has started...
1>------ Start of generation: Project: Custom_Node_test, Configuration: Debug Any CPU ------
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2364,5): warning MSB3270: The processor architecture of the "MSIL" project being generated does not correspond to that of the reference "ProtoGeometry, Version=2.16.0.2365, Culture=neutral, processorArchitecture=AMD64", "AMD64". This can cause run-time failures. Try changing your project's targeted processor architecture using Configuration Manager to use the same processor architectures between your project and the benchmarks, or choose a dependency on the benchmarks whose processor architecture matches to the targeted processor architecture of your project.
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2364,5): warning MSB3270: The processor architecture of the "MSIL" project being generated does not correspond to that of the "RevitAPI", "AMD64" reference. This can cause run-time failures. Try changing your project's targeted processor architecture using Configuration Manager to use the same processor architectures between your project and the benchmarks, or choose a dependency on the benchmarks whose processor architecture matches to the targeted processor architecture of your project.
1> Custom_Node_essay -> C:\Users\33645\source\repos\cus2\cus2\bin\Debug\Custom_Node_Essai.dll
========== Build: 1 success(s), 0 failure(s), 0 current, 0 skip(s) ==========
========= Build started at 2:49 PM and took 01.057 seconds ==========

cordially
christian.stan

If you want ignore this message with platform, just need add this line in configuration .csproj of project

 <PlatformTarget>x64</PlatformTarget>

At the moment is Any CPU

2 Likes