Sharing 'Zero Touch Nodes' on other computers

Hello,

I have recently ran into an issue with a custom ‘Zero Touch Node’. I can build the node in visual studio, and import it on the machine that I built it on, however when I try to import the .dll on a different computer I get the error “Failed to Load Library”.

I have a suspicion this is due to not having all the dependency .dll files, but is there an output setting in visual studio to fix this?

  • Jed

Please read this: How to get help on the Dynamo forums

Did you say this because I don’t have code or screenshots, or something else I am doing wrong?

1 Like

I believe it is this.

We don’t know WHAT DLLs you might be creating dependencies on. We don’t know how you referencing these into your VS solution. Most of the DLLs should be on other user’s computers as well, but unless we know which one’s you importing into your code, and how, we can’t help you.

If library fails to load into Dynamo, the error is posted to console. It would help to get that. You will know what’s causing the issue.

Well, in general ANY kind of information is better than NO information at all.

Well the code works, its just when I move to a different machine importing the .dll doesn’t work. Anyways here is the whole code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.DesignScript.Runtime;
using Autodesk.DesignScript.Interfaces;
using Autodesk.DesignScript.Geometry;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
using RevitServices.Persistence;
using RevitServices.Transactions;
using Revit.GeometryConversion;

///////////////////////////////////////////////////////////////////
/// NOTE: This project requires references to the DynamoServices
/// and ProtoGeometry DLLs. These can be found in the latest
/// ZeroTouch and DynamoServices Nuget packages.
///////////////////////////////////////////////////////////////////

namespace ColorElements
{
    public class ColorElements
    {
        // Two private variables for example purposes
        private double _a;
        private double _b;

        // We make the constructor for this object internal because the 
        // Dynamo user should construct an object through a static method
        internal ColorElements(double a, double b)
        {
            _a = a;
            _b = b;
        }

        public static List<float> createColor(float red, float green, float blue)
        {
            List<float> Color = new List<float>();
            Color.Add(red);
            Color.Add(green);
            Color.Add(blue);
            return Color;
        }
         
        public static string ColorElementsInViews(List<Revit.Elements.Element> elements, List<Revit.Elements.Views.View> views, Revit.Elements.FillPatternElement fillPattern, List<float> fillColor, List<float> lineColor, float lineWeight) 
        {
            string errorReport = "";
            try
            {
                // Create and modify graphics settings
                Autodesk.Revit.DB.OverrideGraphicSettings gSettings = new OverrideGraphicSettings();
                FillPatternElement unwrappedPattern = fillPattern.InternalElement as FillPatternElement;
                gSettings.SetProjectionFillPatternId(unwrappedPattern.Id);
                Color fill = new Color((byte)(int)fillColor[0], (byte)(int)fillColor[1], (byte)(int)fillColor[2]);
                Color line = new Color((byte)(int)lineColor[0], (byte)(int)lineColor[1], (byte)(int)lineColor[2]);
                gSettings.SetProjectionFillColor(fill);
                gSettings.SetProjectionLineColor(line);
                gSettings.SetProjectionLineWeight((int)lineWeight);

                // Ensure in transaction
                Document doc = DocumentManager.Instance.CurrentUIDocument.Document;
                TransactionManager.Instance.EnsureInTransaction(doc);

                // For every element, if in views color
                foreach (Revit.Elements.Element e in elements)
                {
                    Element unwrapped = e.InternalElement;
                    ElementId id = unwrapped.Id;
          
                    foreach (Revit.Elements.Views.View v in views)
                    {
                        View unwrappedView = v.InternalElement as View;
                        unwrappedView.SetElementOverrides(id, gSettings);
                    }
                }
                TransactionManager.Instance.TransactionTaskDone();
                errorReport = "success";
            }
            catch(Exception c)
            {
                errorReport += c.ToString();
            }
            return errorReport;
        }

        public static string ColorListElementsInViews(List<List<Revit.Elements.Element>> elementList, List<Revit.Elements.Views.View> views, Revit.Elements.FillPatternElement fillPattern, List<List<float>> fillColorList, List<float> lineColor, float lineWeight)
        {
            string errorReport = "";
            try
            {
                // Element List and Color List must match
                if (elementList.Count != fillColorList.Count)
                {
                    errorReport = "Element list and color list must be the same length!";
                    throw new Exception();
                }
                for(int i = 0; i < elementList.Count; i++)
                {
                    // Create and modify graphics settings
                    Autodesk.Revit.DB.OverrideGraphicSettings gSettings = new OverrideGraphicSettings();

                    FillPatternElement unwrappedPattern = fillPattern.InternalElement as FillPatternElement; 
                    Color fill = new Color((byte)(int)fillColorList[i][0], (byte)(int)fillColorList[i][1], (byte)(int)fillColorList[i][2]);
                    Color line = new Color((byte)(int)lineColor[0], (byte)(int)lineColor[1], (byte)(int)lineColor[2]);

                    gSettings.SetProjectionFillPatternId(unwrappedPattern.Id);
                    gSettings.SetProjectionFillColor(fill);
                    gSettings.SetProjectionLineColor(line);
                    gSettings.SetProjectionLineWeight((int)lineWeight);

                    // Ensure in transaction
                    Document doc = DocumentManager.Instance.CurrentUIDocument.Document;
                    TransactionManager.Instance.EnsureInTransaction(doc);

                    // For every element, if in views color
                    foreach (Revit.Elements.Element e in elementList[i])
                    {
                        Element unwrapped = e.InternalElement;
                        ElementId id = unwrapped.Id;

                        foreach (Revit.Elements.Views.View v in views)
                        {
                            View unwrappedView = v.InternalElement as View;
                            unwrappedView.SetElementOverrides(id, gSettings);
                        }
                    }
                    TransactionManager.Instance.TransactionTaskDone();
                    errorReport = "success";
                }
            }
            catch (Exception c)
            {
                errorReport += c.ToString();
            }
            return errorReport;
        }

        public static string Clear(List<Revit.Elements.Element> elements, List<Revit.Elements.Views.View> views)
        {
            string errorReport = "";
            try
            {
                Autodesk.Revit.DB.OverrideGraphicSettings gSettings = new OverrideGraphicSettings();
                Document doc = DocumentManager.Instance.CurrentUIDocument.Document;
                TransactionManager.Instance.EnsureInTransaction(doc);

                // For every element, if in views color
                foreach (Revit.Elements.Element e in elements)
                {
                    Element unwrapped = e.InternalElement;
                    ElementId id = unwrapped.Id;

                    foreach (Revit.Elements.Views.View v in views)
                    {
                        View unwrappedView = v.InternalElement as View;
                        unwrappedView.SetElementOverrides(id, gSettings);
                    }
                }
                TransactionManager.Instance.TransactionTaskDone();
                errorReport = "success";
            }
            catch(Exception x)
            {
                errorReport = x.ToString();
            }        
            return errorReport;
        }
    }
}

Doesn’t look like I can do a zip or dll upload, so hope this helps. I was hoping someone has had this issue before and its just a build setting

So try creating a package (make it an internal package if you are not ready to share). The import functionality tends to misbehave sometimes. See if that help.

Turns out it was the coworkers computers used an older version of dynamo, where as I used the newest. Thanks for the help

I had a similar problem and reported it on the Git. I fixed it by opening up the .dyn in IDE and deleting the assembly reference. Then it will load your library because it isn’t hard coded. “not sure if this is the same thing”

Thank you so much, maybe this will come up again in the future for me!

Here is my conversation on github

Hi All,
I have the same issue it works on the developer’s computer, and when I share the DLL file, on one computer it works and for the other computer it comes up this error:

dynamo024

All computers are using the latest Dynamo version.

1 Like