修改命名空间
This commit is contained in:
48
ShrlAlgoToolkit.RevitCore/Extensions/ParameterExtensions.cs
Normal file
48
ShrlAlgoToolkit.RevitCore/Extensions/ParameterExtensions.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using ShrlAlgoToolkit.RevitCore.Assists;
|
||||
|
||||
using System.Reflection;
|
||||
namespace ShrlAlgoToolkit.RevitCore.Extensions;
|
||||
|
||||
public static class ParameterExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置参数对象对用户是否可见.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
/// <param name="visible"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SetVisibility(this Parameter parameter, bool visible)
|
||||
{
|
||||
var parameterIntPtr = parameter.ToParamDef();
|
||||
|
||||
if (parameterIntPtr == IntPtr.Zero)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var result = EncryptParameters.InvokeModule("ParamDef.setUserVisible", [parameterIntPtr, visible]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将参数对象转为非托管指针.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
/// <returns></returns>
|
||||
public static IntPtr ToParamDef(this Parameter parameter)
|
||||
{
|
||||
try
|
||||
{
|
||||
var m = typeof(Parameter).GetMethod("getParamDef", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
return (m?.Invoke(parameter, null) as Pointer).ToIntPtr();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user