/// <summary> /// Modifies the instance definition geometry and replaces all references /// to the current definition with references to the new definition. /// </summary> /// <param name="idefIndex">The index of the instance definition to be modified.</param> /// <param name="newGeometry">The new geometry.</param> /// <param name="newAttributes">The new attributes.</param> /// <returns>true if operation succeeded.</returns> public bool ModifyGeometry(int idefIndex, IEnumerable <GeometryBase> newGeometry, IEnumerable <ObjectAttributes> newAttributes) { using (SimpleArrayGeometryPointer g = new SimpleArrayGeometryPointer(newGeometry)) { IntPtr ptr_array_attributes = UnsafeNativeMethods.ON_SimpleArray_3dmObjectAttributes_New(); if (newAttributes != null) { foreach (ObjectAttributes att in newAttributes) { IntPtr const_ptr_attributes = att.ConstPointer(); UnsafeNativeMethods.ON_SimpleArray_3dmObjectAttributes_Add(ptr_array_attributes, const_ptr_attributes); } } IntPtr const_ptr_geometry = g.ConstPointer(); bool rc = UnsafeNativeMethods.CRhinoInstanceDefinitionTable_ModifyGeometry(m_doc.m_docId, idefIndex, const_ptr_geometry, ptr_array_attributes); UnsafeNativeMethods.ON_SimpleArray_3dmObjectAttributes_Delete(ptr_array_attributes); return(rc); } }
/// <summary> /// Adds an instance definition to the instance definition table. /// </summary> /// <param name="name">The definition name.</param> /// <param name="description">The definition description.</param> /// <param name="basePoint">A base point.</param> /// <param name="geometry">An array, a list or any enumerable set of geometry.</param> /// <param name="attributes">An array, a list or any enumerable set of attributes.</param> /// <returns> /// >=0 index of instance definition in the instance definition table. -1 on failure. /// </returns> /// <example> /// <code source='examples\vbnet\ex_createblock.vb' lang='vbnet'/> /// <code source='examples\cs\ex_createblock.cs' lang='cs'/> /// <code source='examples\py\ex_createblock.py' lang='py'/> /// </example> public int Add(string name, string description, Point3d basePoint, IEnumerable <GeometryBase> geometry, IEnumerable <ObjectAttributes> attributes) { using (SimpleArrayGeometryPointer g = new SimpleArrayGeometryPointer(geometry)) { IntPtr ptr_array_attributes = UnsafeNativeMethods.ON_SimpleArray_3dmObjectAttributes_New(); if (attributes != null) { foreach (ObjectAttributes att in attributes) { IntPtr const_ptr_attributes = att.ConstPointer(); UnsafeNativeMethods.ON_SimpleArray_3dmObjectAttributes_Add(ptr_array_attributes, const_ptr_attributes); } } IntPtr const_ptr_geometry = g.ConstPointer(); int rc = UnsafeNativeMethods.CRhinoInstanceDefinitionTable_Add(m_doc.m_docId, name, description, basePoint, const_ptr_geometry, ptr_array_attributes); UnsafeNativeMethods.ON_SimpleArray_3dmObjectAttributes_Delete(ptr_array_attributes); return(rc); } }