public int ExplodeHatch(MRhinoDoc doc, Guid hatchGuid, ref List<Guid> objectGuids)
        {
            int objectGuids_Count = objectGuids.Count;

              if (null != doc)
              {
            IRhinoHatch hatchObject = MRhinoHatch.ConstCast(doc.LookupObject(hatchGuid));
            if (null != hatchObject)
            {
              MRhinoObject[] subObjects = null;
              int subObjects_Count = hatchObject.GetSubObjects(out subObjects);
              if (0 < subObjects_Count || null != subObjects)
              {
            for (int i = 0; i < subObjects_Count; i++)
            {
              bool rc = doc.AddObject(subObjects[i]);
              if (rc)
                objectGuids.Add(subObjects[i].Attributes().m_uuid);
            }
              }
            }
              }

              return objectGuids.Count - objectGuids_Count;
        }
Beispiel #2
0
        public int ExplodeHatch(MRhinoDoc doc, Guid hatchGuid, ref List <Guid> objectGuids)
        {
            int objectGuids_Count = objectGuids.Count;

            if (null != doc)
            {
                IRhinoHatch hatchObject = MRhinoHatch.ConstCast(doc.LookupObject(hatchGuid));
                if (null != hatchObject)
                {
                    MRhinoObject[] subObjects       = null;
                    int            subObjects_Count = hatchObject.GetSubObjects(out subObjects);
                    if (0 < subObjects_Count || null != subObjects)
                    {
                        for (int i = 0; i < subObjects_Count; i++)
                        {
                            bool rc = doc.AddObject(subObjects[i]);
                            if (rc)
                            {
                                objectGuids.Add(subObjects[i].Attributes().m_uuid);
                            }
                        }
                    }
                }
            }

            return(objectGuids.Count - objectGuids_Count);
        }
Beispiel #3
0
        int CreateInstanceDefinition(MRhinoDoc doc, IOnInstanceDefinition idef, IOn3dPoint point, List <IRhinoObject> objects, bool bQuietly)
        {
            int found_index = doc.m_instance_definition_table.FindInstanceDefinition(idef.Name(), true);
            List <IRhinoObject> idef_objects = new List <IRhinoObject>();

            OnXform xform = new OnXform();

            xform.Translation(new On3dPoint(OnUtil.On_origin) - point);

            for (int i = 0; i < objects.Count; i++)
            {
                IRhinoObject obj = objects[i];
                if (obj == null)
                {
                    continue;
                }

                if (obj.ObjectType() == IOn.object_type.light_object ||
                    obj.ObjectType() == IOn.object_type.grip_object ||
                    obj.ObjectType() == IOn.object_type.phantom_object
                    )
                {
                    continue;
                }

                // Transform geometry and attributes, but do not add to the document
                MRhinoObject dupe = doc.TransformObject(obj, xform, false, false, false);
                if (dupe != null)
                {
                    if (doc.AddObject(dupe, false, true))
                    {
                        idef_objects.Add(dupe);
                    }
                }
            }

            if (idef_objects.Count < 1)
            {
                return(-1);
            }

            int idef_index = -1;

            if (found_index < 0)
            {
                idef_index = doc.m_instance_definition_table.AddInstanceDefinition(idef, idef_objects.ToArray(), false, bQuietly);
            }
            else if (doc.m_instance_definition_table.ModifyInstanceDefinitionGeometry(found_index, idef_objects.ToArray(), bQuietly))
            {
                idef_index = found_index;
                doc.m_instance_definition_table.ModifyInstanceDefinition(idef, idef_index, (uint)IDEF_SETTINGS.all_idef_settings, bQuietly);

                if (!bQuietly)
                {
                    IRhinoInstanceObject[] iref_object_list = null;
                    int iref_count = doc.m_instance_definition_table[found_index].GetReferences(out iref_object_list);
                    if (iref_count > 0)
                    {
                        RhUtil.RhinoApp().Print(string.Format("{0} Instances of block \"{1}\" have been updated.\n", iref_count, idef.Name()));
                    }
                }
            }

            if (idef_index < 0 && !bQuietly)
            {
                string message = (found_index < 0) ? "Error creating block.\n" : "Error modifying block.\n";
                RhUtil.RhinoApp().Print(message);
            }

            return(idef_index);
        }
        int CreateInstanceDefinition(MRhinoDoc doc, IOnInstanceDefinition idef, IOn3dPoint point, List<IRhinoObject> objects, bool bQuietly)
        {
            int found_index = doc.m_instance_definition_table.FindInstanceDefinition(idef.Name(), true);
              List<IRhinoObject> idef_objects = new List<IRhinoObject>();

              OnXform xform = new OnXform();
              xform.Translation(new On3dPoint(OnUtil.On_origin) - point);

              for (int i = 0; i < objects.Count; i++)
              {
            IRhinoObject obj = objects[i];
            if (obj == null)
              continue;

            if (obj.ObjectType() == IOn.object_type.light_object ||
            obj.ObjectType() == IOn.object_type.grip_object ||
            obj.ObjectType() == IOn.object_type.phantom_object
              )
              continue;

            // Transform geometry and attributes, but do not add to the document
            MRhinoObject dupe = doc.TransformObject(obj, xform, false, false, false);
            if (dupe != null)
            {
              if (doc.AddObject(dupe, false, true))
            idef_objects.Add(dupe);
            }
              }

              if (idef_objects.Count < 1)
            return -1;

              int idef_index = -1;

              if (found_index < 0)
            idef_index = doc.m_instance_definition_table.AddInstanceDefinition(idef, idef_objects.ToArray(), false, bQuietly);
              else if (doc.m_instance_definition_table.ModifyInstanceDefinitionGeometry(found_index, idef_objects.ToArray(), bQuietly))
              {
            idef_index = found_index;
            doc.m_instance_definition_table.ModifyInstanceDefinition(idef, idef_index, (uint)IDEF_SETTINGS.all_idef_settings, bQuietly);

            if (!bQuietly)
            {
              IRhinoInstanceObject[] iref_object_list = null;
              int iref_count = doc.m_instance_definition_table[found_index].GetReferences(out iref_object_list);
              if (iref_count > 0)
            RhUtil.RhinoApp().Print(string.Format("{0} Instances of block \"{1}\" have been updated.\n", iref_count, idef.Name()));
            }
              }

              if (idef_index < 0 && !bQuietly)
              {
            string message = (found_index < 0) ? "Error creating block.\n" : "Error modifying block.\n";
            RhUtil.RhinoApp().Print(message);
              }

              return idef_index;
        }