public static List<NamedValue> ConvertToNamedValueList(IntPtr pXmlSection) { if (IntPtr.Zero == pXmlSection) return null; List<Rhino.Render.NamedValue> list = new List<NamedValue>(); IntPtr pIterator = UnsafeNativeMethods.Rdk_XmlSection_GetIterator(pXmlSection); //Fill the property list from the XML section if (pIterator != IntPtr.Zero) { while (true) { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { Variant variant = new Variant(); if (1 == UnsafeNativeMethods.Rdk_XmlSection_NextParam(pXmlSection, pIterator, sh.ConstPointer(), variant.ConstPointer())) { NamedValue nv = new NamedValue(sh.ToString(), variant.AsObject()); list.Add(nv); } else break; } } UnsafeNativeMethods.Rdk_XmlSection_DeleteIterator(pIterator); } return list; }
/// <summary> /// Override this function to provide information about which texture is used for /// the standard (ie - defined in ON_Texture) texture channels. /// </summary> /// <param name="slot">An valid slot.</param> /// <returns>The texture used for the channel.</returns> public virtual string TextureChildSlotName(StandardChildSlots slot) { if (IsNativeWrapper()) { StringIds iString = StringIds.DiffuseChildSlotName; switch (slot) { case StandardChildSlots.Diffuse: iString = StringIds.DiffuseChildSlotName; break; case StandardChildSlots.Transparency: iString = StringIds.TransparencyChildSlotName; break; case StandardChildSlots.Bump: iString = StringIds.BumpChildSlotName; break; case StandardChildSlots.Environment: iString = StringIds.EnvironmentChildSlotName; break; } return(GetString(iString)); } using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.Rdk_RenderMaterial_CallTextureChildSlotNameBase(ConstPointer(), pString, (int)slot); return(sh.ToString()); } }
public override string ToString() { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { UnsafeNativeMethods.Rdk_Variant_GetStringValue(ConstPointer(), sh.NonConstPointer()); return(sh.ToString()); } }
/// <summary> /// Gets the next unused layer name used as default when creating new layers. /// </summary> /// <param name="ignoreDeleted"> /// If this is true then Rhino may use a name used by a deleted layer. /// </param> /// <returns>An unused layer name string.</returns> /// <example> /// <code source='examples\vbnet\ex_addlayer.vb' lang='vbnet'/> /// <code source='examples\cs\ex_addlayer.cs' lang='cs'/> /// <code source='examples\py\ex_addlayer.py' lang='py'/> /// </example> public string GetUnusedLayerName(bool ignoreDeleted) { using (Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.CRhinoLayerTable_GetUnusedLayerName(m_doc.m_docId, ignoreDeleted, pString); return(sh.ToString()); } }
public string GetUnusedDimensionStyleName() { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pStringHolder = sh.NonConstPointer(); UnsafeNativeMethods.CRhinoDimStyleTable_GetUnusedDimensionStyleName(m_doc.m_docId, pStringHolder); return(sh.ToString()); } }
/// <summary> /// Gets localized unit system name. Uses current application locale id. /// </summary> /// <param name="units">The unit system.</param> /// <param name="capitalize">true if the name should be capitalized.</param> /// <param name="singular">true if the name is expressed for a singular element.</param> /// <param name="abbreviate">true if name should be the abbreviation.</param> /// <returns>The unit system name.</returns> public static string UnitSystemName(UnitSystem units, bool capitalize, bool singular, bool abbreviate) { using (var sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.CRhinoApp_UnitSystemName((int)units, capitalize, singular, abbreviate, pString); return(sh.ToString()); } }
public static string StringFromProjection(BackgroundProjections projection) { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.Rdk_SimulatedTexture_StringFromProjection(pString, (int)projection); return(sh.ToString()); } }
public string GetUnusedInstanceDefinitionName(string root, uint defaultSuffix) { using (Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.CRhinoInstanceDefinitionTable_GetUnusedName3(m_doc.m_docId, root, defaultSuffix, pString); return(sh.ToString()); } }
/* * /// <summary> * /// Shows the content chooser to allow the user to select a new or existing content. * /// </summary> * /// <param name="defaultType">The content type that will be initially selected in the 'New' tab.</param> * /// <param name="defaultInstanceId">The content instance that will be initially selected in the 'Existing' tab.</param> * /// <param name="kinds">Which content kinds will be displayed.</param> * /// <param name="instanceIdOut">The UUID of the chosen item. Depending on eRhRdkSccResult, this can be the type id of a content type or the instance id of an existing content.</param> * /// <param name="flags">Tabs specifications.</param> * /// <param name="doc">A Rhino document.</param> * /// <returns>The result.</returns> * public static ShowContentChooserResults ShowContentChooser(Guid defaultType, Guid defaultInstanceId, RenderContentKind kinds, ref Guid instanceIdOut, ShowContentChooserFlags flags, RhinoDoc doc) * { * return (ShowContentChooserResults)UnsafeNativeMethods.Rdk_Globals_ShowContentChooser(defaultType, defaultInstanceId, RenderContent.KindString(kinds), ref instanceIdOut, (int)flags, doc.m_docId); * } */ /// <summary> /// Finds a file and also handles network shares. /// <remarks>This is a replacement for CRhinoFileUtilities::FindFile().</remarks> /// </summary> /// <param name="fullPathToFile">The file to be found.</param> /// <returns>The found file.</returns> public static string FindFile(string fullPathToFile) { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); bool found = (1 == UnsafeNativeMethods.Rdk_Globals_FindFile(fullPathToFile, pString)); return(found ? sh.ToString() : null); } }
// <summary> // Accesses any content table given a (single) kind. // </summary> // <param name="kind">A single kind.</param> // <param name="doc">A Rhino document.</param> // <returns>The (render content kind) list.</returns> //public static ContentList ContentList(RenderContentKind kind, RhinoDoc doc) //{ // return new ContentList(kind, doc); //} /// <summary> /// Prompts the user for a save file name and the width, height and depth of an image to be saved. /// </summary> /// <param name="filename">The original file path.</param> /// <param name="width">A width.</param> /// <param name="height">An height.</param> /// <param name="colorDepth">A color depth.</param> /// <returns>The new file name.</returns> public static string PromptForSaveImageFileParameters(string filename, ref int width, ref int height, ref int colorDepth) { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); bool bRet = 1 == UnsafeNativeMethods.Rdk_Globals_PromptForSaveImageFileParams(filename, ref width, ref height, ref colorDepth, pString); if (bRet) { return(sh.ToString()); } } return(null); }
internal static ConstructionPlane FromIntPtr(IntPtr pConstructionPlane) { if (IntPtr.Zero == pConstructionPlane) return null; ConstructionPlane rc = new ConstructionPlane(); using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.ON_3dmConstructionPlane_Copy(pConstructionPlane, ref rc.m_plane, ref rc.m_grid_spacing, ref rc.m_snap_spacing, ref rc.m_grid_line_count, ref rc.m_grid_thick_frequency, ref rc.m_bDepthBuffered, pString); rc.m_name = sh.ToString(); } return rc; }
public RenderPlugInList() { IntPtr pList = UnsafeNativeMethods.Rdk_RenderPlugInInfo_New(); if (pList != IntPtr.Zero) { bool b = true; while (b) { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); Guid uuid = new Guid(); b = 1 == UnsafeNativeMethods.Rdk_RenderPlugInInfo(pList, ref uuid, pString); Add(new RenderPlugInInfo(uuid, pString.ToString())); } } UnsafeNativeMethods.Rdk_RenderPlugInInfo_Delete(pList); } }
internal static ConstructionPlane FromIntPtr(IntPtr pConstructionPlane) { if (IntPtr.Zero == pConstructionPlane) { return(null); } ConstructionPlane rc = new ConstructionPlane(); using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.ON_3dmConstructionPlane_Copy(pConstructionPlane, ref rc.m_plane, ref rc.m_grid_spacing, ref rc.m_snap_spacing, ref rc.m_grid_line_count, ref rc.m_grid_thick_frequency, ref rc.m_bDepthBuffered, pString); rc.m_name = sh.ToString(); } return(rc); }
public static List <NamedValue> ConvertToNamedValueList(IntPtr pXmlSection) { if (IntPtr.Zero == pXmlSection) { return(null); } List <Rhino.Render.NamedValue> list = new List <NamedValue>(); IntPtr pIterator = UnsafeNativeMethods.Rdk_XmlSection_GetIterator(pXmlSection); //Fill the property list from the XML section if (pIterator != IntPtr.Zero) { while (true) { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { Variant variant = new Variant(); if (1 == UnsafeNativeMethods.Rdk_XmlSection_NextParam(pXmlSection, pIterator, sh.ConstPointer(), variant.ConstPointer())) { NamedValue nv = new NamedValue(sh.ToString(), variant.AsObject()); list.Add(nv); } else { break; } } } UnsafeNativeMethods.Rdk_XmlSection_DeleteIterator(pIterator); } return(list); }
/// <summary> /// Gets the debug dumps. This is a text description of the geometric contents. /// DebugDump() is intended for debugging and is not suitable for creating high /// quality text descriptions of an object. /// </summary> /// <param name="geometry">Some geometry.</param> /// <returns>A debug dump text.</returns> public static string DebugDumpToString(Rhino.Geometry.GeometryBase geometry) { IntPtr pConstThis = geometry.ConstPointer(); using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.ON_Object_Dump(pConstThis, pString); return sh.ToString(); } }
/// <summary> /// Gets an array of most recent command descriptions. /// </summary> /// <returns>An array of command descriptions.</returns> public static MostRecentCommandDescription[] GetMostRecentCommands() { IntPtr pDisplayStrings = UnsafeNativeMethods.ON_StringArray_New(); IntPtr pMacros = UnsafeNativeMethods.ON_StringArray_New(); int count = UnsafeNativeMethods.CRhinoApp_GetMRUCommands(pDisplayStrings, pMacros); MostRecentCommandDescription[] rc = new MostRecentCommandDescription[count]; using(var sh = new Rhino.Runtime.StringHolder() ) { IntPtr pString = sh.NonConstPointer(); for (int i = 0; i < count; i++) { var mru = new MostRecentCommandDescription(); UnsafeNativeMethods.ON_StringArray_Get(pDisplayStrings, i, pString); mru.DisplayString = sh.ToString(); UnsafeNativeMethods.ON_StringArray_Get(pMacros, i, pString); mru.Macro = sh.ToString(); rc[i] = mru; } } UnsafeNativeMethods.ON_StringArray_Delete(pDisplayStrings); UnsafeNativeMethods.ON_StringArray_Delete(pMacros); return rc; }
/// <summary> /// A "child slot" is the specific "slot" that a child (usually a texture) occupies. /// This is generally the "use" of the child - in other words, the thing the child /// operates on. Some examples are "color", "transparency". /// </summary> /// <param name="childSlotName">The named of the child slot to receive the parameter name for.</param> /// <returns>The default behaviour for these functions is to return the input string. Sub-classes may (in the future) override these functions to provide different mappings.</returns> public string ParamNameFromChildSlotName(String childSlotName) { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); IntPtr pConstThis = ConstPointer(); UnsafeNativeMethods.Rdk_RenderContent_ParamNameFromChildSlotName(pConstThis, childSlotName, pString); return sh.ToString(); } }
static AppearanceSettingsState CreateState(bool current) { IntPtr pAppearanceSettings = UnsafeNativeMethods.CRhinoAppAppearanceSettings_New(current); AppearanceSettingsState rc = new AppearanceSettingsState(); using (Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.CRhinoAppearanceSettings_DefaultFontFaceNameGet(pString, pAppearanceSettings); rc.DefaultFontFaceName = sh.ToString(); } rc.DefaultLayerColor = GetColor(idxDefaultLayerColor, pAppearanceSettings); rc.SelectedObjectColor = GetColor(idxSelectedObjectColor, pAppearanceSettings); rc.LockedObjectColor = GetColor(idxLockedObjectColor, pAppearanceSettings); rc.WorldCoordIconXAxisColor = GetColor(idxWorldIconXColor, pAppearanceSettings); rc.WorldCoordIconYAxisColor = GetColor(idxWorldIconYColor, pAppearanceSettings); rc.WorldCoordIconZAxisColor = GetColor(idxWorldIconZColor, pAppearanceSettings); rc.TrackingColor = GetColor(idxTrackingColor, pAppearanceSettings); rc.FeedbackColor = GetColor(idxFeedbackColor, pAppearanceSettings); rc.DefaultObjectColor = GetColor(idxDefaultObjectColor, pAppearanceSettings); rc.ViewportBackgroundColor = GetColor(idxViewportBackgroundColor, pAppearanceSettings); rc.FrameBackgroundColor = GetColor(idxFrameBackgroundColor, pAppearanceSettings); rc.CommandPromptTextColor = GetColor(idxCommandPromptTextColor, pAppearanceSettings); rc.CommandPromptHypertextColor = GetColor(idxCommandPromptHypertextColor, pAppearanceSettings); rc.CommandPromptBackgroundColor = GetColor(idxCommandPromptBackgroundColor, pAppearanceSettings); rc.CrosshairColor = GetColor(idxCrosshairColor, pAppearanceSettings); rc.PageviewPaperColor = GetColor(idxPageviewPaperColor, pAppearanceSettings); rc.CurrentLayerBackgroundColor = GetColor(idxCurrentLayerBackgroundColor, pAppearanceSettings); rc.EchoPromptsToHistoryWindow = UnsafeNativeMethods.CRhinoAppAppearanceSettings_GetBool(idxEchoPromptsToHistoryWindow, pAppearanceSettings); rc.EchoCommandsToHistoryWindow = UnsafeNativeMethods.CRhinoAppAppearanceSettings_GetBool(idxEchoCommandsToHistoryWindow, pAppearanceSettings); rc.ShowFullPathInTitleBar = UnsafeNativeMethods.CRhinoAppAppearanceSettings_GetBool(idxFullPathInTitleBar, pAppearanceSettings); rc.ShowCrosshairs = UnsafeNativeMethods.CRhinoAppAppearanceSettings_GetBool(idxCrosshairsVisible, pAppearanceSettings); UnsafeNativeMethods.CRhinoAppAppearanceSettings_Delete(pAppearanceSettings); // also add grid settings IntPtr pGridSettings = UnsafeNativeMethods.CRhinoAppGridSettings_New(current); rc.GridThickLineColor = GetGridColor(idxThickLineColor, pGridSettings); rc.GridThinLineColor = GetGridColor(idxThinLineColor, pGridSettings); rc.GridXAxisLineColor = GetGridColor(idxXAxisColor, pGridSettings); rc.GridYAxisLineColor = GetGridColor(idxYAxisColor, pGridSettings); rc.GridZAxisLineColor = GetGridColor(idxZAxisColor, pGridSettings); UnsafeNativeMethods.CRhinoAppGridSettings_Delete(pGridSettings); return rc; }
/// <summary> /// Override this function to provide information about which texture is used for /// the standard (ie - defined in ON_Texture) texture channels. /// </summary> /// <param name="slot">An valid slot.</param> /// <returns>The texture used for the channel.</returns> public virtual string TextureChildSlotName(StandardChildSlots slot) { if (IsNativeWrapper()) { StringIds iString = StringIds.DiffuseChildSlotName; switch (slot) { case StandardChildSlots.Diffuse: iString = StringIds.DiffuseChildSlotName; break; case StandardChildSlots.Transparency: iString = StringIds.TransparencyChildSlotName; break; case StandardChildSlots.Bump: iString = StringIds.BumpChildSlotName; break; case StandardChildSlots.Environment: iString = StringIds.EnvironmentChildSlotName; break; } return GetString(iString); } using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.Rdk_RenderMaterial_CallTextureChildSlotNameBase(ConstPointer(), pString, (int)slot); return sh.ToString(); } }
/// <summary> /// Finds a file and also handles network shares. /// <remarks>This is a replacement for CRhinoFileUtilities::FindFile().</remarks> /// </summary> /// <param name="fullPathToFile">The file to be found.</param> /// <returns>The found file.</returns> public static string FindFile(string fullPathToFile) { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); bool found = (1 == UnsafeNativeMethods.Rdk_Globals_FindFile(fullPathToFile, pString)); return found ? sh.ToString() : null; } }
/// <summary> /// Prompts the user for a save file name and the width, height and depth of an image to be saved. /// </summary> /// <param name="filename">The original file path.</param> /// <param name="width">A width.</param> /// <param name="height">An height.</param> /// <param name="colorDepth">A color depth.</param> /// <returns>The new file name.</returns> public static string PromptForSaveImageFileParameters(string filename, ref int width, ref int height, ref int colorDepth) { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); bool bRet = 1==UnsafeNativeMethods.Rdk_Globals_PromptForSaveImageFileParams(filename, ref width, ref height, ref colorDepth, pString); if (bRet) return sh.ToString(); } return null; }
/// <summary> /// Gets a localized short descriptive name of the object. /// </summary> /// <param name="plural">true if the descriptive name should in plural.</param> /// <returns>A string with the short localized descriptive name.</returns> public string ShortDescription(bool plural) { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pConstThis = ConstPointer(); IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.CRhinoObject_ShortDescription(pConstThis, pString, plural); return sh.ToString(); } }
public static string StringFromProjection(BackgroundProjections projection) { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.Rdk_SimulatedTexture_StringFromProjection(pString, (int)projection); return sh.ToString(); } }
public override string ToString() { using (Rhino.Runtime.StringHolder sh = new Rhino.Runtime.StringHolder()) { UnsafeNativeMethods.Rdk_Variant_GetStringValue(ConstPointer(), sh.NonConstPointer()); return sh.ToString(); } }
/// <summary> /// Gets localized unit system name. Uses current application locale id. /// </summary> /// <param name="units">The unit system.</param> /// <param name="capitalize">true if the name should be capitalized.</param> /// <param name="singular">true if the name is expressed for a singular element.</param> /// <param name="abbreviate">true if name should be the abbreviation.</param> /// <returns>The unit system name.</returns> public static string UnitSystemName(UnitSystem units, bool capitalize, bool singular, bool abbreviate) { using (var sh = new Rhino.Runtime.StringHolder()) { IntPtr pString = sh.NonConstPointer(); UnsafeNativeMethods.CRhinoApp_UnitSystemName((int)units, capitalize, singular, abbreviate, pString); return sh.ToString(); } }