Hi,

It would be very helpful to have the ability to easily bring curves from Blender to Curve Architect.

Bezier curves from Blender can be easily exported to JSON files using this plugin:
https://github.com/basementstudio/blender-bezier-exporter

Using this plugin, a point on a curve will contain the following data:
{
"id": 1,
"px": -736.761658,
"py": -430.261108,
"pz": -68.995331,
"hlx": -739.540833,
"hly": -439.125000,
"hlz": -69.111023,
"hrx": -733.631348,
"hry": -421.484985,
"hrz": -68.849464
}

Due to the only requirement being a conversion, this shouldn't even be too hard to implement, I guess.

I think transferring a curve to Unity is not an unusual scenario, especially if you designed some roads in Blender and want to get them to Unity without recreating it manually.

For an example, I've created a curve based on a real-world street in Blender. The street is pretty long and complex (a mountain road), so it would be a not insignificant effort to completely recreate it in Unity by hand.

Also: Is the API already capable of creating a curve programmatically?
With a little advise on this, I maybe can create a script by myself...

Thanks a lot,
Void

    Hello,

    Thank you for your suggestion and for being the first person besides me to comment on this forum. 🙂

    I will likely add this feature to Curve Architect. If everything goes as planned, I will update Curve Architect next week. I don't know if this will be included in that update, but it will likely be in the one after that.

    Currently, you can achieve this with a script, and it's not that hard to do.

    Example:

        using UnityEngine;
        using UnityEditor;
    
        using CurveArchitect.Objects;
    
        public static class MenuItems
        {
            [MenuItem("GameObject/3D Object/Architect Curve Json", false, 100)]
            public static void CreateDeformCurveFromJson()
            {
                GameObject go = new GameObject("ArchitectCurve from json");
                ArchitectCurve ac = go.AddComponent<ArchitectCurve>();
                go.AddComponent<ArchitectCurveCache>();
    
                //Load data from json and and set positions for anchors and tangents.
                HandleSegement.CreateSegement(ac, 0, new Vector3(0, 0, 0), new Vector3(3, 0, 0), new Vector3(-3, 0, 0));
                HandleSegement.CreateSegement(ac, 0, new Vector3(0, 0, 8), new Vector3(3, 0, 8), new Vector3(-3, 0, 8));
            }
        }

    Note: Remember that your script needs to be within an "Editor" folder. You can place this folder wherever you want, but it needs to be named "Editor." Otherwise, you won't be able to access the Editor part of the "CurveArchitect" namespace.

      Thank you very much for considering to implement this feature.

      I created a script using a other approach then in your example:

      using System;
      using CurveArchitect;
      using CurveArchitect.Objects;
      using UnityEngine;
      
      public class ArchitectCurveFromJson : MonoBehaviour
      {
          public TextAsset _inputData;
          public bool _yUp = true;
      
          public void CreateDeformCurveFromJson(BezierPoint[] bezierPoints)
          {
              ArchitectCurve ac = gameObject.AddComponent<ArchitectCurve>();
              gameObject.AddComponent<ArchitectCurveCache>();
              for (int i = 0; i < bezierPoints.Length; i++)
              {
                  BezierPoint p = bezierPoints[i];
                  HandleSegement.CreateSegement(ac, i, 
                      new Vector3(p.px, _yUp ? p.pz : p.py, _yUp ? p.py : p.pz),
                      new Vector3(p.hrx, _yUp ? p.hrz : p.hry, _yUp ? p.hry : p.hrz),
                      new Vector3(p.hlx, _yUp ? p.hlz : p.hly, _yUp ? p.hly : p.hlz)
                      );
              }
          }
      
          private BezierPoint[] ReadJSON(string str)
          {
              BezierPointWrapper jsonData = JsonUtility.FromJson<BezierPointWrapper>("{\"Items\":" + str + "}");
              return jsonData.Items;
          }
      
          public void run()
          {
              var data = ReadJSON(_inputData.text);
              CreateDeformCurveFromJson(data);
          }
      
      }
      
      [Serializable]
      public class BezierPoint
      {
          public int id;
          public float px, py, pz, hlx, hly, hlz, hrx, hry, hrz;
      }
      
      [Serializable]
      public class BezierPointWrapper
      {
          public BezierPoint[] Items;
      }

      And:

      using UnityEngine;
      using UnityEditor;
      
      [CustomEditor(typeof(ArchitectCurveFromJson))]
      public class ArchitectCurveFromJsonEditor : Editor
      {
          public override void OnInspectorGUI()
          {
              ArchitectCurveFromJson architectCurveFromJson = (ArchitectCurveFromJson)target;
      
              DrawDefaultInspector();
      
              if (GUILayout.Button("Create ArchitectCurve from JSON"))
              {
                  architectCurveFromJson.run();
              }
          }
      }

      You can attach this script to an empty game object. Select a JSON file containing the output from the Blender addon and hit the button. I only did a short test but it seems to work well. 🙂

      A little addition: I noticed, the Architect curve is mirrored after importing. I don't know why. Reversing the imported array doesn't seem to help.

        Blender handles the X, Y, and Z axes differently from Unity. You might want to switch the Z axis and the X axis.