#if _never
using BiMMApi;
namespace FeMM.Grasshopper.Components
{
public class BiMMExportComponent : GH_Component
{
protected bool _run;
/// <summary>
/// Initializes a new instance of the ChecksComponent class.
/// </summary>
public BiMMExportComponent()
: base("BiMM sync", "BiMM", "Syncronize the current model with the Revit model", "FeMM", "10-Export")
{
_run = false;
}
public override void CreateAttributes()
{
var attr = new ComponentOneButtonAttributes(this, "Syncronize");
attr.ButtonPressed += () =>
{
_run = true;
ExpireSolution(true);
};
m_attributes = attr;
}
/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddGenericParameter("Model", "M", "The model to syncronize", GH_ParamAccess.item);
pManager.AddTextParameter("Title", "T", "The title of the revit file where syncronize", GH_ParamAccess.item);
}
/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_OutputParamManager pManager)
{
}
/// <summary>
/// This is the method that actually does the work.
/// </summary>
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
protected override void SolveInstance(IGH_DataAccess DA)
{
Message = "";
GH_Model model = null;
string docTitle = null;
if (!DA.GetData("Model", ref model))
return;
if (!DA.GetData("Title", ref docTitle))
return;
if (_run)
{
var errors = new List<string>();
try
{
IBiMMApi api = ApiHelper.Connect();
if (api == null)
{
throw new NotSupportedException("Unable to connect with BiMM. Please check if Revit is running");
}
if (api.CheckConnection())
{
api.StartTransactionGroup(docTitle);
Point3d from, to;
from = new Point3d(0, 0, 0);
to = new Point3d(50, 0, 0);
for (int i = 0; i < 20; i++)
{
api.CreateWall(from.X, from.Y, from.Z, to.X, to.Y, to.Z);
from += new Point3d(0, 5, 0);
to += new Point3d(0, 5, 0);
}
api.CommitTransactionGroup();
}
}
catch (Exception ex)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, ex.Message);
return;
}
finally
{
_run = false;
foreach (string err in errors)
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, err);
}
}
}
}
/// <summary>
/// Provides an Icon for the component.
/// </summary>
protected override System.Drawing.Bitmap Icon => Properties.Resources.BiMMExportIcon;
/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid => new Guid("DB7C5F62-6962-4926-A5F2-931CAAD7CEFE");
}
}
#endif