예제 #1
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Types.BcEntity bcEnt = null;
            if (!DA.GetData("BuildingElement", ref bcEnt))
            {
                return;
            }

            Types.PropCategory propertyCategory = null;
            DA.GetData("PropCategory", ref propertyCategory);
            var objectId = bcEnt.ObjectId;

            if (propertyCategory != null)
            {
                var props  = Bricscad.Bim.BIMClassification.GetPropertiesMap(objectId);
                var catStr = propertyCategory.Value.ToCategoryString();
                var res    = props.Where(propData => propData.Value == catStr)
                             .Select(propData => propData.Key)
                             .ToList();
                DA.SetDataList("Names", res);
            }
            else
            {
                DA.SetDataList("Names", Bricscad.Bim.BIMClassification.GetPropertiesString(objectId));
            }
        }
예제 #2
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Types.BcEntity bcEnt = null;
            if (!DA.GetData("BuildingElement", ref bcEnt))
            {
                return;
            }

            var geom = new Bricscad.Bim.BIMLinearGeometry(bcEnt.ObjectId);

            if (geom != null)
            {
                var axis          = geom.GetAxis();
                var extrusionPath = geom.GetExtrusionPath();
                var profileCurves = geom.GetProfile();
                if (axis != null)
                {
                    DA.SetData("Axis", axis.ToRhino());
                }
                if (extrusionPath != null)
                {
                    DA.SetData("ExtrusionPath", extrusionPath.ToRhino());
                }
                if (profileCurves.Count != 0)
                {
                    var curves = new List <Curve>();
                    profileCurves.ForEach(loop => loop.ForEach(geCurve => curves.Add(geCurve.ToRhino())));
                    DA.SetDataList("ProfileCurves", curves);
                }
            }
        }
예제 #3
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Types.BcEntity bcEnt        = null;
            string         propertyName = null;

            Types.PropCategory propertyCategory = null;

            if (!DA.GetData("BuildingElement", ref bcEnt) ||
                !DA.GetData("PropName", ref propertyName) ||
                !DA.GetData("PropCategory", ref propertyCategory))
            {
                return;
            }

            var objectId = bcEnt.ObjectId;

            if (!Bricscad.Bim.BIMClassification.HasProperty(objectId, propertyName, propertyCategory.Value))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, string.Format("Property with name \"{0}\" does not exist", propertyName));
                return;
            }
            try
            {
                var propertyValue = Bricscad.Bim.BIMClassification.GetProperty(objectId, propertyName, propertyCategory.Value);
                if (propertyValue == null)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, string.Format("Failed to obtain property with name \"{0}\"", propertyName));
                    return;
                }
                DA.SetData("PropVal", propertyValue);
            }
            catch { }
        }
        public static void Run(GH_Document definition, GrasshopperData ghData, _BcAp.Document bcDoc)
        {
            bool saveState = GH_Document.EnableSolutions;

            GH_Document.EnableSolutions = true;
            definition.Enabled          = true;

            var inputs       = GetInputParams(definition);
            var hostEntityId = ghData.HostEntity;

            foreach (var input in inputs)
            {
                if (!IsInputName(input.NickName))
                {
                    continue;
                }

                if (input is Parameters.BcEntity)
                {
                    input.ClearData();
                    var data = new Types.BcEntity(hostEntityId.ToFsp(), bcDoc.Name);
                    input.AddVolatileData(new Grasshopper.Kernel.Data.GH_Path(0), 0, data);
                    data.LoadGeometry(bcDoc);
                    continue;
                }

                var prop = ghData.GetProperty(FormatName(input.NickName));
                if (prop == null)
                {
                    continue;
                }

                input.VolatileData.ClearData();
                switch (prop)
                {
                case int intValue:
                case double doubleValue:
                case bool boolValue:
                case string strValue:
                    input.AddVolatileData(new Grasshopper.Kernel.Data.GH_Path(0), 0, prop);
                    break;

                case _OdGe.Point3d pntValue:
                    input.AddVolatileData(new Grasshopper.Kernel.Data.GH_Path(0), 0, pntValue.ToRhino());
                    break;

                case _OdGe.Vector3d vecValue:
                    input.AddVolatileData(new Grasshopper.Kernel.Data.GH_Path(0), 0, vecValue.ToRhino());
                    break;
                }
            }

            Rhino.RhinoApp.SetFocusToMainWindow();
            definition.NewSolution(false, GH_SolutionMode.Silent);
            Rhinoceros.Run();

            GH_Document.EnableSolutions = saveState;
        }
예제 #5
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Types.BcEntity bcEnt         = null;
            string         propertyName  = null;
            IGH_Goo        propertyValue = null;

            Types.PropCategory propertyCategory = null;

            if (!DA.GetData("BuildingElement", ref bcEnt) ||
                !DA.GetData("PropName", ref propertyName) ||
                !DA.GetData("PropVal", ref propertyValue) ||
                !DA.GetData("PropCategory", ref propertyCategory))
            {
                return;
            }

            var    objectId = bcEnt.ObjectId;
            object val      = null;

            switch (propertyValue.ScriptVariable())
            {
            case string strVal: val = strVal; break;

            case int intVal: val = intVal; break;

            case double dblVal: val = dblVal; break;
            }
            if (val == null)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error,
                                  string.Format("Conversion failed from {0} to string, int or double", propertyValue.TypeName));
                return;
            }

            if (!Bricscad.Bim.BIMClassification.HasProperty(objectId, propertyName, propertyCategory.Value))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, string.Format("Property with name \"{0}\" does not exist", propertyName));
                return;
            }

            if (Bricscad.Bim.BIMClassification.SetProperty(objectId, propertyName, val, propertyCategory.Value) != Bricscad.Bim.BimResStatus.Ok)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error,
                                  string.Format("Failed to set property \"{0}\" for object {1}", propertyName, bcEnt.PersistentRef));
            }
        }