- 1 AnyGeometry
- 1.1 AnyCurve
- 1.2 AnyGroup
- 1.3 AnyPoint
- 1.4 AnySolid
- 1.5 AnySurface
- 1.6 PolyfaceHeader
- 1.7 SingleLineText
1 AnyGeometry
说明:所有通用几何的基础接口,即所有的MS所有的几何都继承自AnyGeometry
方法:
属性:
1.1 AnyCurve
说明:
方法:
属性:
1.1.1 CurvePrimitive
说明:创建几何曲线
方法:
AdjustFractionToBreakFraction()
功能说明:将指定位置的fraction移动到break fraction
代码示例:
public void AdjustFractionToBreakFractionTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//利用上一步骤中点列表创建CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
//使用该方法将起点处的fraction移动到附近断点所在的fraction,
//其中参数RoundingMode 有三个值,分别是up down 和round
curvePrimitive.AdjustFractionToBreakFraction(0, RoundingMode.Up, out uint fractionIndex, out double outFraction);
MessageBox.Show("the adjust fraction is " + outFraction.ToString());
}
Clone()
功能说明:深拷贝曲线
代码示例:
public void CloneTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//利用上一步骤中点列表创建CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
// 使用Clone()方法将curvePrimitive深拷贝一份
CurvePrimitive curvePrimitive1 = curvePrimitive.Clone();
//将CurvePrimitive转为Element, 持久化到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive1, null); //将CurvePrimitive转为Element, 持久化到model中
element1.AddToModel();
}
CloneBetweenFractions()
功能说明:深拷贝两个fraction之间的曲线
代码示例:
public void CloneBetweenFractionsTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//利用上一步骤中点列表创建CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
curvePrimitive.Length(out double totalLength);
//通过PointAtSignedDistanceFromFraction方法获取线串在固定位置的位置信息;通过其返回值CurveLocationDetail的Fraction获得曲线1/4 1/2处的fraction
CurveLocationDetail curveLocationDetail0 = curvePrimitive.PointAtSignedDistanceFromFraction(0.0, totalLength / 4, false);
CurveLocationDetail curveLocationDetail1 = curvePrimitive.PointAtSignedDistanceFromFraction(0.0, totalLength / 2, false);
//使用CloneBetweenFractions方法复制 1/4 1/2之间的曲线
CurvePrimitive curvePrimitive1 = curvePrimitive.CloneBetweenFractions(curveLocationDetail0.Fraction, curveLocationDetail1.Fraction, false);
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive1, null); //将CurvePrimitive转为Element, 持久化到model中
element1.AddToModel();
}
CloneDereferenced()
功能说明:
代码示例:
ClosestPointBounded()
功能说明:计算曲线上到指定空间点距离最近的点; 有两个重载
代码示例:
public void ClosestPointBoundedTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//利用上一步骤中点列表创建CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
DPoint3d spacePt = new DPoint3d(10000, 20000, 10000);
CurveLocationDetail curveLocationDetail = curvePrimitive.ClosestPointBounded(spacePt);
DSegment3d dSegment3d = new DSegment3d(spacePt, curveLocationDetail.Point);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3d);
lineElement.AddToModel();
}
public void ClosestPointBoundedTest2()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//利用上一步骤中点列表创建CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
DPoint3d spacePt = new DPoint3d(10000, 20000, 10000);
//使用方法获取空间点到曲线的最近点和对应的fraction
bool result = curvePrimitive.ClosestPointBounded(spacePt,out double fraction, out DPoint3d outPoint);
//将获取到的点和空间点连成线段,持久化到model中
DSegment3d dSegment3d = new DSegment3d(spacePt, outPoint);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3d);
lineElement.AddToModel();
MessageBox.Show("the fraction of closest point is" + fraction.ToString());
}
ClosestPointBoundedXY()
功能说明:计算曲线投影到XY面上以后,到空间点距离最近的点
代码示例:
public void ClosestPointBoundedXYTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 10000));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 10000));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 10000));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 10000));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 10000));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 10000));
//利用上一步骤中点列表创建CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
DPoint3d spacePt = new DPoint3d(10000, 20000, 10000);
//使用ClosestPointBoundedXY方法获取曲线上到空间点最近的点,将两个点连城线段,持久化到mdoel中
CurveLocationDetail curveLocationDetail = curvePrimitive.ClosestPointBoundedXY(spacePt, DMatrix4d.Identity);
DSegment3d dSegment3d = new DSegment3d(spacePt, curveLocationDetail.Point);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3d);
lineElement.AddToModel();
}
CreateArc(**)**
功能说明:创建圆弧,是CurvePrimitive的静态方法;输入参数是DEllipse3d类型
代码示例:
public static void CurvePrimitiveExample_CreateArc()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
DEllipse3d dEllipse3D = new DEllipse3d(0 * UorPerMas, 5 * UorPerMas, 0 * UorPerMas, 10 * UorPerMas, 10 * UorPerMas, 0 * UorPerMas); //创建DEllipse3d
CurvePrimitive curvePrimitive = CurvePrimitive.CreateArc(dEllipse3D);// 使用CurvePrimitive下的静态方法CreateArc
//CurvePrimitive的两个属性
bool m_IsExtenSilbleFractionSpace = curvePrimitive.IsExtensibleFractionSpace;
bool m_IsMappableFractionSpace = curvePrimitive.IsMappableFractionSpace;
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element.AddToModel();
}
CreateBsplineCurve()
功能说明:创建B样条曲线,是CurvePrimitive的静态方法;该方法有三个重载,详见代码示例
代码示例:
public static void CurvePrimitiveExample_CreateBsplineCurve()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
CurvePrimitive curvePrimitive = CurvePrimitive.CreateBsplineCurve();// 使用CurvePrimitive下的静态方法CreateBsplineCurve, 该方法创建了一个空的B样条曲线对象
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0,0,0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
List<double> weight = new List<double>() ;
List<double> knot = new List<double>() ;
CurvePrimitive curvePrimitive0 = CurvePrimitive.CreateBsplineCurve(dPoint3Ds, weight, knot, 2, false, true);// 使用CurvePrimitive下的静态方法CreateBsplineCurve
Element element0 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive0, null);//将CurvePrimitive转为Element, 持久化到model中
element0.AddToModel();
List<DPoint3d> dPoint3Dsss = new List<DPoint3d>();
dPoint3Dsss.Add(new DPoint3d(0, 0, 0));
dPoint3Dsss.Add(new DPoint3d(-10000, 10000, 0));
dPoint3Dsss.Add(new DPoint3d(-20000, 60000, 0));
dPoint3Dsss.Add(new DPoint3d(-40000, -10000, 0));
dPoint3Dsss.Add(new DPoint3d(-70000, 20000, 0));
dPoint3Dsss.Add(new DPoint3d(-90000, -40000, 0));
MSBsplineCurve mSBsplineCurve = MSBsplineCurve.CreateFromAkima(dPoint3Dsss.ToArray()); //要求最少有6个点
CurvePrimitive curvePrimitive1 = CurvePrimitive.CreateBsplineCurve(mSBsplineCurve);// 使用CurvePrimitive下的静态方法CreateBsplineCurve
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive1, null); //将CurvePrimitive转为Element, 持久化到model中
element1.AddToModel();
}
CreateChildCurveVectorCopyFromSource()
功能说明:从源CurveVector创建一个几何曲线,是对源CurveVector的深度拷贝,拷贝后源CurveVector没有被清理;输入参数是CurveVector类型;
代码示例:
public static void CurvePrimitiveExample_CreateChildCurveVectorCopyFromSource()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//创建CurveVector为下一步骤做做准备
CurveVector curves = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.None, false);
//使用CurvePrimitive的静态函数CreateChildCurveVectorCopyFromSource新建一个CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateChildCurveVectorCopyFromSource(curves);
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
}
CreateChildCurveVectorSwapFromSource()
功能说明:从源CurveVector创建一个几何曲线,拷贝后源CurveVector被清除掉,这是与上个方法的区别所在;输入参数是CurveVector类型;
代码示例:
public static void CurvePrimitiveExample_CreateChildCurveVectorSwapFromSource()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//创建CurveVector为下一步骤做做准备
CurveVector curves = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.None, false);
//使用CurvePrimitive的静态函数CreateChildCurveVectorSwapFromSource新建一个CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateChildCurveVectorSwapFromSource(curves);
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
}
CreateFromNative()
功能说明:从指针创建曲线
代码示例:
public void CreateFromNativeTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
CurvePrimitive curvePrimitive0 = CurvePrimitive.CreateLineString(dPoint3Ds);
IntPtr intPtr = CurvePrimitive.DereferenceToNative(curvePrimitive0, true);
CurvePrimitive curvePrimitive = CurvePrimitive.CreateFromNative(intPtr);
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
}
CreateInterpolationCurve()
功能说明:使用创建MS插值曲线的方法创建CurvePrimitive
代码示例:
public static void CurvePrimitiveExample_CreateInterpolationCurve()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//创建样条曲线结束方向
List<DVector3d> dVector3Ds = new List<DVector3d>();
dVector3Ds.Add(new DVector3d(dPoint3Ds[4], dPoint3Ds[5]));
//创建MS的插值曲线
MSInterpolationCurve mSInterpolationCurve = MSInterpolationCurve.CreateFromPointsAndEndTangents(dPoint3Ds,true,300.0,dVector3Ds,false, true, true, true);
//利用上一步骤中的M插值曲线创建CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateInterpolationCurve(mSInterpolationCurve);
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
}
CreateLine()
功能说明:使用创建线的方法创建CurvePrimitive
代码示例:
public static void CurvePrimitiveExample_CreateLine()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
//创建线节段 DSegment3d
DSegment3d dSegment3D = new DSegment3d(dPoint3Ds[0], dPoint3Ds[1]);
//利用上一步骤中的线节段 DSegment3d创建CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLine(dSegment3D);
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
}
CreateLineString()
功能说明:使用创建线串的方法创建CurvePrimitive
代码示例:
public static void CurvePrimitiveExample_CreateLineString()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//利用上一步骤中点列表创建CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
}
CreatePartialCurve()
功能说明:使用父曲线(CurvePrimitive)创建新的同类型曲线;方法会修改父曲线对象
代码示例:
public static void CurvePrimitiveExample_CreatePartialCurve()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//利用点列表创建CurvePrimitive0
CurvePrimitive curvePrimitive0 = CurvePrimitive.CreateLineString(dPoint3Ds);
//将curvePrimitive0作为入参输入到CreatePartialCurve方法中,创建新的curvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreatePartialCurve(curvePrimitive0,0.3,0.7,1);
//将 创建后的子几何曲线CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
//将父几何曲线CurvePrimitive0转为Element, 持久化到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive0, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
//最终的执行结果, 添加到model中的CurvePrimitive是两条相同的曲线
}
CreatePointString()
功能说明:从点列表直接创建线串几何
代码示例:
public static void CurvePrimitiveExample_CreatePointString()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用点列表直接创建线串
CurvePrimitive curvePrimitive = CurvePrimitive.CreatePointString(dPoint3Ds);
//将创建的CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
}
CreateSpiralBearingRadiusBearingRadius()
功能说明:按照曲线类型创建不同类型的螺旋线;第一个参数transitionType 的值对应的曲线类型
static const int TransitionType_Unknown = 0;
static const int TransitionType_Clothoid = 10; 回旋曲线
static const int TransitionType_Bloss = 11; 布劳斯曲线
static const int TransitionType_Biquadratic = 12; 四次幂
static const int TransitionType_Cosine = 13; 余弦曲线
static const int TransitionType_Sine = 14; 正弦曲线
static const int TransitionType_Viennese = 20; 维也纳
static const int TransitionType_WeightedViennese = 21; 加权维也纳
第二个参数 startRadians 开始弧度(注意取值范围 0~2Pi)
代码示例:
public static void CurvePrimitiveExample_CreateSpiralBearingRadiusBearingRadius()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
CurvePrimitive curvePrimitive = CurvePrimitive.CreateSpiralBearingRadiusBearingRadius(10,0,200.0,2*Math.PI,10000,DTransform3d.Identity,0.0,1.0);
/* 第一个整型参数 transitionType 的值对应的曲线类型
static const int TransitionType_Unknown = 0;
static const int TransitionType_Clothoid = 10; 回旋曲线
static const int TransitionType_Bloss = 11; 布劳斯曲线
static const int TransitionType_Biquadratic = 12; 四次幂
static const int TransitionType_Cosine = 13; 余弦曲线
static const int TransitionType_Sine = 14; 正弦曲线
static const int TransitionType_Viennese = 20; 维也纳
static const int TransitionType_WeightedViennese = 21; 加权维也纳
第二个参数 startRadians 开始弧度
startRadius 开始半径
*/
//将创建的CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
}
CreateStrongTypeFromNativeICurvePrimitive ()
功能说明:使用CurvePrimitive的指针创建新的曲线,有两个参数,第一个是现存曲线的指针,第二个是创建方式:CreateAction.Capture,直接将源曲线的指针作为新创建曲线的指针,二者使用同一块内存;CreateAction.Clone,在内存中开辟新的区域,作为新创建曲线的存储区域;在代码示例中,分别获取了三条曲线的指针,使用CreateAction.Capture参数的指针与源曲线一致,使用CreateAction.Clone的指针与源曲线不同。
代码示例:
public static void CurvePrimitiveExample_CreateStrongTypeFromNativeICurvePrimitive()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用点列表直接创建线串
CurvePrimitive curvePrimitive = CurvePrimitive.CreatePointString(dPoint3Ds);
//获取curvePrimitive曲线的指针
IntPtr intPtr = CurvePrimitive.DereferenceToNative(curvePrimitive, true);
//使用源曲线的指针,CreateAction.Capture参数创建新的曲线,并且获取创建后曲线的指针
CurvePrimitive curvePrimitive0 = CurvePrimitive.CreateStrongTypeFromNativeICurvePrimitive(intPtr, CreateAction.Capture);
IntPtr intPtr0 = CurvePrimitive.DereferenceToNative(curvePrimitive0, true);
//使用源曲线的指针,CreateAction.Clone参数创建新的曲线,并且获取创建后曲线的指针
CurvePrimitive curvePrimitive1 = CurvePrimitive.CreateStrongTypeFromNativeICurvePrimitive(intPtr, CreateAction.Clone);
IntPtr intPtr1 = CurvePrimitive.DereferenceToNative(curvePrimitive1, true);
//将创建的CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null); //将CurvePrimitive转为Element, 持久化到model中
element.AddToModel();
Element element0 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive0, null); //将CurvePrimitive转为Element, 持久化到model中
element0.AddToModel();
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive1, null); //将CurvePrimitive转为Element, 持久化到model中
element1.AddToModel();
//将源曲线的指针和两种参数创建曲线的指针组合为字符串,并显示到窗口;我们可以看到源曲线和使用Capture参数创建曲线的指针是一致的, 使用后clone参数创建的曲线与源曲线的指针不一致
//虽然在model中,创建的三条曲线重叠显示在在同一位置, 但它们的创建方式和创建时的方法是不同的
string mess = "sourceCurveIntPtr is" + intPtr + "\n captureActionCurveIntPtr is " + intPtr0 + "\n cloneActionCurveIntPtr is " + intPtr1;
MessageBox.Show(mess);
}
DereferenceToNative ()
功能说明:各种曲线类型的基本接口;获取CurvePrimitive曲线的指针
代码示例:
public static void CurvePrimitiveExample_DereferenceToNative()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用点列表直接创建线串
CurvePrimitive curvePrimitive = CurvePrimitive.CreatePointString(dPoint3Ds);
//获取curvePrimitive曲线的指针
IntPtr intPtr = CurvePrimitive.DereferenceToNative(curvePrimitive,true);
//将指针转化为字符串,使用消息盒子显示出来
string PtrString = intPtr.ToString();
MessageBox.Show(PtrString);
}
Dispose()
功能说明:
代码示例:
FastMaxAbs()
功能说明:该方法返回一个double类型的曲线坐标值最大的绝对值;并不一定返回真正意义上曲线上坐标绝对值的最大值,也可能会返回样条曲线极点中坐标值最大的绝对值;
代码示例:
public static void CurvePrimitiveExample_FastMaxAbs()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -200000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -100000, 0));
//使用点列表直接创建线串
CurvePrimitive curvePrimitive = CurvePrimitive.CreatePointString(dPoint3Ds);
//FastMaxAbs()方法返回一个double类型的曲线坐标值最大的绝对值
double value = curvePrimitive.FastMaxAbs();
//将返回值转为字符串,显示在窗口中
string valueString = value.ToString();
MessageBox.Show(valueString);
}
FractionToFrenetFrame ()
功能说明:out类型的输出参数获取参数化曲线上某点处的变换矩阵;方法的返回值是布尔类型,如果曲线不是参数化曲线,方法会返回flase
代码示例:
public static void CurvePrimitiveExample_FractionToFrenetFrame()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//绘制一个0度到360度的一个螺旋线,其起始半径为200,终止半径为10000 (都是UOR单位)
CurvePrimitive curvePrimitive = CurvePrimitive.CreateSpiralBearingRadiusBearingRadius(10, 0, 200.0, 2 * Math.PI, 10000, DTransform3d.Identity, 0.0, 1.0);
//FractionToFrenetFrame获取参数化曲线上某点处的变换矩阵;如果曲线不是参数化曲线,方法会返回flase
curvePrimitive.FractionToFrenetFrame(0.1,out DTransform3d dTransform3D);
TransformInfo transformInfo = new TransformInfo(dTransform3D);
//创建点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(0, 10000, 0));
//创建shape元素,将原始的shape元素添加到model中
ShapeElement shape = new ShapeElement(dgnModel, null, dPoint3Ds.ToArray());
shape.AddToModel();
//对原始的shape元素应用变换矩阵后,也添加到model中,观察两次添加shape元素的位置
shape.ApplyTransform(transformInfo);
shape.AddToModel();
}
FractionToPoint(Double, DPoint3d)
功能说明:out类型的输出参数返回参数化曲线上某点处的坐标;方法的返回值是布尔类型,如果曲线不是参数化曲线,方法会返回flase
代码示例:
public static void CurvePrimitiveExample_FractionToPoint0()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//绘制一个0度到360度的一个螺旋线,其起始半径为200,终止半径为10000 (都是UOR单位)
CurvePrimitive curvePrimitive = CurvePrimitive.CreateSpiralBearingRadiusBearingRadius(10, 0, 200.0, 2 * Math.PI, 10000, DTransform3d.Identity, 0.0, 1.0);
//重载1 获取曲线上某点的坐标
curvePrimitive.FractionToPoint(0.5, out DPoint3d dPoint3D);
//创建一条起点为0,终点为曲线中点的直线,并持久化到model中
DSegment3d dSegment3D = new DSegment3d(new DPoint3d(0, 0, 0), dPoint3D);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
FractionToPoint(Double, DPoint3d, DVector3d)
功能说明:out类型的输出参数返回参数化曲线上某点处的坐标,和该点处的切线方向;方法的返回值是布尔类型,如果曲线不是参数化曲线,方法会返回flase
代码示例:
public static void CurvePrimitiveExample_FractionToPoint1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//绘制一个0度到360度的一个螺旋线,其起始半径为200,终止半径为10000 (都是UOR单位)
CurvePrimitive curvePrimitive = CurvePrimitive.CreateSpiralBearingRadiusBearingRadius(10, 0, 200.0, 2 * Math.PI, 10000, DTransform3d.Identity, 0.0, 1.0);
//重载2 获取曲线上某点的坐标,曲线上该点处的切向量(一阶导数)
curvePrimitive.FractionToPoint(0.1, out DPoint3d dPoint3D,out DVector3d dVector3D);
//获取切向量的终点
DPoint3d endPoint3D = DPoint3d.Add(dPoint3D, dVector3D);
//创建一条起点在曲线上,终点为切向量终点的直线,并持久化到model中
DSegment3d dSegment3D = new DSegment3d(dPoint3D, endPoint3D);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
FractionToPoint(Double, DPoint3d, DVector3d, DVector3d)
功能说明:out类型的输出参数返回参数化曲线上某点处的坐标,曲线上该点处的切向量(一阶导数)和二阶导数;方法的返回值是布尔类型,如果曲线不是参数化曲线,方法会返回flase
代码示例:
public static void CurvePrimitiveExample_FractionToPoint2()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//绘制一个0度到360度的一个螺旋线,其起始半径为200,终止半径为10000 (都是UOR单位)
CurvePrimitive curvePrimitive = CurvePrimitive.CreateSpiralBearingRadiusBearingRadius(10, 0, 200.0, 2 * Math.PI, 10000, DTransform3d.Identity, 0.0, 1.0);
//重载3 获取曲线上某点的坐标,曲线上该点处的切向量(一阶导数)和二阶导数
curvePrimitive.FractionToPoint(0.1, out DPoint3d dPoint3D, out DVector3d dVector3D, out DVector3d dVector3D1);
//获取二阶导数向量的终点
DPoint3d endPoint3D = DPoint3d.Add(dPoint3D, dVector3D1);
//创建一条起点在曲线上,终点为二阶导数向量终点的直线,并持久化到model中
DSegment3d dSegment3D = new DSegment3d(dPoint3D, endPoint3D);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
FractionToPoint(Double, DPoint3d, DVector3d, DVector3d, DVector3d)
功能说明:out类型的输出参数返回参数化曲线上某点处的坐标,曲线上该点处的切向量(一阶导数)和二阶导数,三阶导数;方法的返回值是布尔类型,如果曲线不是参数化曲线,方法会返回flase
代码示例:
public static void CurvePrimitiveExample_FractionToPoint3()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//绘制一个0度到360度的一个螺旋线,其起始半径为200,终止半径为10000 (都是UOR单位)
CurvePrimitive curvePrimitive = CurvePrimitive.CreateSpiralBearingRadiusBearingRadius(10, 0, 200.0, 2 * Math.PI, 10000, DTransform3d.Identity, 0.0, 1.0);
//重载4 获取曲线上某点的坐标,曲线上该点处的切向量(一阶导数)和二阶导数,三阶导数
curvePrimitive.FractionToPoint(0.1, out DPoint3d dPoint3D, out DVector3d dVector3D, out DVector3d dVector3D1, out DVector3d dVector3D2);
//获取三阶导数向量的终点
DPoint3d endPoint3D = DPoint3d.Add(dPoint3D, dVector3D2);
//创建一条起点在曲线上,终点为三阶导数向量终点的直线,并持久化到model中
DSegment3d dSegment3D = new DSegment3d(dPoint3D, endPoint3D);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
GetBreakFraction ()
功能说明:获得曲线某一断点的fraction值,第一个参数代表想获取第几个断点的索引值
代码示例:
public static void CurvePrimitiveExample_GetBreakFraction()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -200000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -100000, 0));
//使用点列表直接创建线串
CurvePrimitive curvePrimitive = CurvePrimitive.CreatePointString(dPoint3Ds);
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element.AddToModel();
//使用GetBreakFraction方法获取曲线某一断点处的fraction值
curvePrimitive.GetBreakFraction(1,out double fraction);
//将获取到的fraction转为string, 显示在消息框中
string mess = "the first break fraction is " + fraction.ToString();
MessageBox.Show(mess);
}
GetBsplineCurve ()
功能说明:如果曲线是B样条曲线类型的,则返回MSBsplineCurve;如果不是,则返回null
代码示例:
public static void CurvePrimitiveExample_GetBsplineCurve()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -200000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -100000, 0));
List<double> weight = new List<double>();
List<double> knot = new List<double>();
// 使用CurvePrimitive下的静态方法CreateBsplineCurve
CurvePrimitive curvePrimitive0 = CurvePrimitive.CreateBsplineCurve(dPoint3Ds, weight, knot, 2, false, true);
//使用GetBsplineCurve方法获取MSBsplineCurve
MSBsplineCurve mSBsplineCurve0 = curvePrimitive0.GetBsplineCurve();
//如果获取结果为空,则弹出消息提示
if (mSBsplineCurve0 == null)
{
string mess = "在这个CurvePrimitive中不包含B样条曲线";
MessageBox.Show(mess);
}
// 如果获取结果不为空,则将MSBsplineCurve转化为element添加到当前文件中
else
{
CurvePrimitive curvePrimitive00 = CurvePrimitive.CreateBsplineCurve(mSBsplineCurve0);
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive00, null);
element.AddToModel();
}
GetChildCurveVector ()
功能说明:
代码示例:
GetCurvePrimitiveType ()
功能说明:该方法返回CurvePrimitive曲线的类型;不同的整形数字代表不同的曲线类型,详细如下
NotClassified = -1,
None = 0,
Invalid = 0,
Line = 1,
LineString = 2,
Arc = 3,
BsplineCurve = 4,
InterpolationCurve = 5,
AkimaCurve = 6,
PointString = 7,
CurveVector = 8,
Spiral = 9,
PartialCurve = 10
代码示例:
public static void CurvePrimitiveExample_GetCurvePrimitiveType()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -200000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -100000, 0));
//使用CreateLineString方法创建线串类型的CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
//GetCurvePrimitiveType 使用该方法获取所创建曲线的类型
var curvePrimitiveType = curvePrimitive.GetCurvePrimitiveType();
/*
NotClassified = -1,
None = 0,
Invalid = 0,
Line = 1,
LineString = 2,
Arc = 3,
BsplineCurve = 4,
InterpolationCurve = 5,
AkimaCurve = 6,
PointString = 7,
CurveVector = 8,
Spiral = 9,
PartialCurve = 10,
*/
//将所获取的曲线类型在消息框显示出来
MessageBox.Show(curvePrimitiveType.ToString());
}
GetInterpolationCurve ()
功能说明:
代码示例:
GetMarkerBit ()
功能说明:
代码示例:
GetMSBsplineCurve ()
功能说明:
代码示例:
GetProxyBsplineCurve ()
功能说明:
代码示例:
GetRange ()
功能说明:获取一个curvePrimitive对象的包围盒(Range),该方法的返回值是一个bool类型的值,代表获取的结果
代码示例:
public static void CurvePrimitiveExample_GetRange()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用CreateLineString方法创建线串类型的CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
//获取曲线的包围盒(range)
bool result = curvePrimitive.GetRange(out DRange3d dRange3D);
if (result)
{
MessageBox.Show("Get the range of curvePrimitive successfully");
}
}
GetSpiral ()
功能说明:
代码示例:
GetStartEnd(DPoint3d, DPoint3d)
功能说明:该方法获取curvePrimitive的起终点
代码示例:
public static void CurvePrimitiveExample_GetStartEnd()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用CreateLineString方法创建线串类型的CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
// 使用方法获取curvePrimitive的起终点
bool result = curvePrimitive.GetStartEnd(out DPoint3d startPt, out DPoint3d endPt);
//以curvePrimitive的起终点画直线,并添加到model中
DSegment3d dSegment3D = new DSegment3d(startPt, endPt);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
GetStartEnd(DPoint3d, DPoint3d,DVector3d,DVector3d)
功能说明:获取curvePrimitive起终点的重载方法, 不仅能获取到起终点的坐标,并且能获取到起终点的切线
代码示例:
public static void CurvePrimitiveExample_GetStartEnd1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用CreateLineString方法创建线串类型的CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
//获取curvePrimitive起终点的重载方法, 不仅能获取到起终点的坐标,并且能获取到起终点的切线
bool result = curvePrimitive.GetStartEnd(out DPoint3d startPt, out DPoint3d endPt,out DVector3d tangentA,out DVector3d tangentB);
//以curvePrimitive的起终点画直线,并添加到model中
DSegment3d dSegment3D = new DSegment3d(startPt, endPt);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
GetStartPoint ()
功能说明:获取curvePrimitive对象的起点
代码示例:
public static void CurvePrimitiveExample_GetStartPoint()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用CreateLineString方法创建线串类型的CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
//使用GetStartPoint方法获取curvePrimitive对象的起点
bool result = curvePrimitive.GetStartPoint(out DPoint3d startPt);
//将曲线起点的XYZ坐标分别显示到消息窗口中
MessageBox.Show("startPoint's X value is"+startPt.X.ToString() +
"\r\n startPoint's Y value is" + startPt.Y.ToString()+
"\r\n startPoint's Z value is" + startPt.Z.ToString());
}
GetStrokeCount ()
功能说明:
代码示例:
public static void CurvePrimitiveExample_GetStrokeCount()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用CreateLineString方法创建线串类型的CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
FacetOptions facetOptions = new FacetOptions();
facetOptions.SetCurveDefaultsDefaults();
uint result = curvePrimitive.GetStrokeCount(facetOptions, 0.1, 0.5);
MessageBox.Show(result.ToString());
}
IsPeriodicFractionSpace ()
功能说明:如果曲线是周期曲线的一部分,则返回true,否则返回false;在代码示例中用线串和圆分别举例子
代码示例:
public static void CurvePrimitiveExample_IsPeriodicFractionSpace()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用CreateLineString方法创建线串类型的CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
//使用CreateArc方法创建圆类型的CurvePrimitive
DEllipse3d dEllipse3D = new DEllipse3d(0 * UorPerMas, 5 * UorPerMas, 0 * UorPerMas, 10 * UorPerMas, 10 * UorPerMas, 0 * UorPerMas); //创建DEllipse3d
CurvePrimitive curvePrimitive1 = CurvePrimitive.CreateArc(dEllipse3D);// 使用CurvePrimitive下的静态方法CreateArc
//如果曲线是周期类型的曲线,该方法会返回true, 否则会返回false;使用该方法分别判断线串和圆
bool result = curvePrimitive.IsPeriodicFractionSpace(out double value0);
bool result1 = curvePrimitive1.IsPeriodicFractionSpace(out double value1);
//将判断结果分别显示在消息框中
if (result1)
{
MessageBox.Show("Circle is Periodic Fraction Space, and it's period is " + value1.ToString());
}
else
{
MessageBox.Show("Circle isn't Periodic Fraction Space, and it's period is " + value1.ToString());
}
if (result)
{
MessageBox.Show("LineString is Periodic Fraction Space, and it's period is " + value0.ToString());
}
else
{
MessageBox.Show("LineString isn't Periodic Fraction Space, and it's period is " + value0.ToString());
}
}
IsSameStructure ()
功能说明:判断这个CurvePrimitive和其他的是否具有相同的树结构;若有,则返回true,否则返回false
代码示例:
public static void CurvePrimitiveExample_IsSameStructure()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用CreateLineString方法创建线串类型的CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
//使用CreateArc方法创建圆类型的CurvePrimitive
DEllipse3d dEllipse3D = new DEllipse3d(0 * UorPerMas, 5 * UorPerMas, 0 * UorPerMas, 10 * UorPerMas, 10 * UorPerMas, 0 * UorPerMas); //创建DEllipse3d
CurvePrimitive curvePrimitive1 = CurvePrimitive.CreateArc(dEllipse3D);// 使用CurvePrimitive下的静态方法CreateArc
//使用该方法判断两个curvePrimitive是否是相同的结构
bool result = curvePrimitive.IsSameStructure(curvePrimitive1);
//将返回的结果展示在消息框中
if (result)
{
MessageBox.Show("linString and circle is same structure");
}
else
{
MessageBox.Show("linString and circle isn't same structure");
}
}
IsSameStructureAndGeometry ()
功能说明:断这个CurvePrimitive和其他的是否具有相同的树结构和几何信息;若有,则返回true,否则返回false
代码示例:
public static void CurvePrimitiveExample_IsSameStructureAndGeometry()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//使用CreateArc方法创建圆类型的CurvePrimitive
DEllipse3d dEllipse3D0 = new DEllipse3d(0 * UorPerMas, 5 * UorPerMas, 0 * UorPerMas, 5 * UorPerMas, 10 * UorPerMas, 0 * UorPerMas); //创建DEllipse3d
CurvePrimitive curvePrimitive0 = CurvePrimitive.CreateArc(dEllipse3D0);// 使用CurvePrimitive下的静态方法CreateArc
//使用CreateArc方法创建圆类型的CurvePrimitive
DEllipse3d dEllipse3D1 = new DEllipse3d(0 * UorPerMas, 5 * UorPerMas, 0 * UorPerMas, 10 * UorPerMas, 10 * UorPerMas, 0 * UorPerMas); //创建DEllipse3d
CurvePrimitive curvePrimitive1 = CurvePrimitive.CreateArc(dEllipse3D1);// 使用CurvePrimitive下的静态方法CreateArc
//将两个圆弧or椭圆持久化到model中
Element element0 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive0, null);
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive1, null);
element0.AddToModel();
element1.AddToModel();
// 使用方法判断二者是否具有i相同的结构和几何,将结果展示在消息框中
bool result = curvePrimitive0.IsSameStructureAndGeometry(curvePrimitive1, 0.1);
if (result == false)
{
MessageBox.Show("they have same structure but different Geometry");
}
else
{
MessageBox.Show("they have same structure and Geometry");
}
}
Length ()
功能说明:返回曲线的长度值;如果曲线是不可度量的则返回false
代码示例:
public static void CurvePrimitiveExample_Length()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用CreateLineString方法创建线串类型的CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
//将曲线转为element并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel,curvePrimitive,null);
element.AddToModel();
//使用该方法获取曲线的长度值,将长度值展示在消息框中
curvePrimitive.Length(out double length);
MessageBox.Show("the length of that curve is " + length.ToString());
}
PointAtSignedDistanceFromFraction ()
功能说明:在基本曲线上从一个fraction移动一段距离后,返回基本曲线上某点处的位置信息;方法的参数:startFraction,在曲线上开始的fraction;signedDistance,沿曲线移动的距离;allowExtension,是否支持曲线的延伸;方法的返回值,CurveLocationDetail,曲线位置的详细信息,包含所在点的坐标和此点在曲线上的fraction等。
代码示例:
public static void CurvePrimitiveExample_PointAtSignedDistanceFromFraction()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用CreateLineString方法创建线串类型的CurvePrimitive,将线串转化为元素添加到model中
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element.AddToModel();
// 求出基本曲线上给定位置(曲线终点处)处的坐标点,
curvePrimitive.Length(out double curveLength);
CurveLocationDetail curveLocationDetail = curvePrimitive.PointAtSignedDistanceFromFraction(0.0, curveLength, false);
DPoint3d dPoint3D = curveLocationDetail.Point;
//以曲线的起点和终点画线段,并添加到model中
DSegment3d dSegment3D = new DSegment3d(dPoint3Ds[0], dPoint3D);
LineElement lineElement = new LineElement(dgnModel,null,dSegment3D);
lineElement.AddToModel();
}
SetMarkerBit ()
功能说明:
代码示例:
SetPolesAndOrder ()
功能说明:为已创建的B样条曲线添加数据
代码示例:
public static void CurvePrimitiveExample_SetPolesAndOrder()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<DPoint3d> dPoint3Dsss = new List<DPoint3d>();
dPoint3Dsss.Add(new DPoint3d(0, 0, 0));
dPoint3Dsss.Add(new DPoint3d(-10000, 10000, 0));
dPoint3Dsss.Add(new DPoint3d(-20000, 60000, 0));
dPoint3Dsss.Add(new DPoint3d(-40000, -10000, 0));
dPoint3Dsss.Add(new DPoint3d(-70000, 20000, 0));
dPoint3Dsss.Add(new DPoint3d(-90000, -40000, 0));
//先创建一条B样条曲线,转化为元素,并添加到model中
MSBsplineCurve mSBsplineCurve = MSBsplineCurve.CreateFromAkima(dPoint3Dsss.ToArray()); //要求最少有6个点
CurvePrimitive curvePrimitive1 = CurvePrimitive.CreateBsplineCurve(mSBsplineCurve);// 使用CurvePrimitive下的静态方法CreateBsplineCurve
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive1, null);
element.AddToModel();
//使用该方法为之前步骤创建的B样条曲线添加参数
List<double> knot = new List<double>();
List<double> weight = new List<double>();
curvePrimitive1.SetPolesAndOrder(dPoint3Dsss, weight, knot, 3, false, false);
Element element0 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive1, null);
element0.AddToModel();
}
SignedDistanceBetweenFractions ()
功能说明:返回曲线上两个fraction之间的距离;本例子中使用1/4和1/2处的fraction,注意只有直线中点处的fraction是0.5,其余类型曲线的fraction均可通过例子中的方法获取。如果不是参数化的曲线,则会返回false
代码示例:
public static void CurvePrimitiveExample_SignedDistanceBetweenFractions()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<DPoint3d> dPoint3Dsss = new List<DPoint3d>();
dPoint3Dsss.Add(new DPoint3d(0, 0, 0));
dPoint3Dsss.Add(new DPoint3d(-10000, 10000, 0));
dPoint3Dsss.Add(new DPoint3d(-20000, 60000, 0));
dPoint3Dsss.Add(new DPoint3d(-40000, -10000, 0));
dPoint3Dsss.Add(new DPoint3d(-70000, 20000, 0));
dPoint3Dsss.Add(new DPoint3d(-90000, -40000, 0));
//生成线串,转化为element,并添加到model中
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Dsss);
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element.AddToModel();
//通过length()方法获得线串的总长度
curvePrimitive.Length(out double totalLength);
//通过PointAtSignedDistanceFromFraction方法获取线串在固定位置的位置信息;通过其返回值CurveLocationDetail的Fraction获得曲线1/4 1/2处的fraction
CurveLocationDetail curveLocationDetail0 = curvePrimitive.PointAtSignedDistanceFromFraction(0.0, totalLength / 4, false);
CurveLocationDetail curveLocationDetail1 = curvePrimitive.PointAtSignedDistanceFromFraction(0.0, totalLength / 2, false);
//SignedDistanceBetweenFractions使用该方法获得曲线1/4 1/2之间的距离
curvePrimitive.SignedDistanceBetweenFractions(curveLocationDetail0.Fraction, curveLocationDetail1.Fraction, out double signedDistance);
//将1/4 1/2处的fraction值打印在窗口中;将总长度和1/4 1/2之间的距离打印在窗口中;最后打印出它们之间的距离是4倍的关系
MessageBox.Show("the fraction in 1/4 length is "+ curveLocationDetail0.Fraction.ToString()+
"\n\r the the fraction in 1/2 length is "+ curveLocationDetail1.Fraction.ToString()+
"\n\r the distance between them is "+ signedDistance.ToString()+
"\n\r the total length of lineString is "+ totalLength.ToString()+
"\n\r their quotient is "+ (totalLength/ signedDistance).ToString());
}
Transform ()
功能说明:对曲线进行变换
代码示例:
public static void CurvePrimitiveExample_Transform()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<DPoint3d> dPoint3Dsss = new List<DPoint3d>();
dPoint3Dsss.Add(new DPoint3d(0, 0, 0));
dPoint3Dsss.Add(new DPoint3d(-10000, 10000, 0));
dPoint3Dsss.Add(new DPoint3d(-20000, 60000, 0));
dPoint3Dsss.Add(new DPoint3d(-40000, -10000, 0));
dPoint3Dsss.Add(new DPoint3d(-70000, 20000, 0));
dPoint3Dsss.Add(new DPoint3d(-90000, -40000, 0));
//生成线串,转化为element,并添加到model中
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Dsss);
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element.AddToModel();
DMatrix3d matrix = new DMatrix3d(1, 0, 0, 0, 0, 1, 0, 1, 0);//定义变换矩阵,将Y坐标和Z坐标调换
DTransform3d trans = new DTransform3d(matrix);//定义变换几何
curvePrimitive.Transform(trans);
//应用transform方法对曲线进行变换,将变换的结果转换为element,并添加到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element1.AddToModel();
}
TryAddLineStringPoint ()
功能说明:为线串类型的曲线添加点,方法执行成功后会返回false
代码示例:
public static void CurvePrimitiveExample_TryAddLineStringPoint()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<DPoint3d> dPoint3Dsss = new List<DPoint3d>();
dPoint3Dsss.Add(new DPoint3d(0, 0, 0));
dPoint3Dsss.Add(new DPoint3d(-10000, 10000, 0));
dPoint3Dsss.Add(new DPoint3d(-20000, 60000, 0));
dPoint3Dsss.Add(new DPoint3d(-40000, -10000, 0));
dPoint3Dsss.Add(new DPoint3d(-70000, 20000, 0));
dPoint3Dsss.Add(new DPoint3d(-90000, -40000, 0));
//生成线串,转化为element,并添加到model中
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Dsss);
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element.AddToModel();
DPoint3d dPoint3D = new DPoint3d(-100000, 50000, 0);
//生成线串,为线串添加一个点;方法执行成功后会返回false
bool res = curvePrimitive.TryAddLineStringPoint(ref dPoint3D);
if (!res)
{
//将添加了点的线串转化为element,添加到model中
Element element22 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element22.AddToModel();
}
else
{
MessageBox.Show("TryAddLineStringPoint Failed");
}
}
TryGetArc ()
功能说明:
代码示例:
TryGetLine ()
功能说明:获取线类型曲线的DSegment3d, 若获取成功,则返回flase;示例代码的效果在同一位置生成两条线段
代码示例:
public static void CurvePrimitiveExample_TryGetLine()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<DPoint3d> dPoint3Dsss = new List<DPoint3d>();
dPoint3Dsss.Add(new DPoint3d(-20000, 60000, 0));
dPoint3Dsss.Add(new DPoint3d(-10000, 10000, 0));
//创建线,转为element, 添加到model中
DSegment3d dSegment3D = new DSegment3d(dPoint3Dsss[0], dPoint3Dsss[1]);
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLine(dSegment3D);
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element.AddToModel();
//使用方法获取CurvePrimitive的DSegment3d元素,转化为element,添加到model中
curvePrimitive.TryGetLine(out DSegment3d dSegment3D1);
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element1.AddToModel();
}
TryGetLineString ()
功能说明:返回线串类型曲线的点列表,其他类型的曲线,会返回null
代码示例:
public static void CurvePrimitiveExample_TryGetLineString()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<DPoint3d> dPoint3Dsss = new List<DPoint3d>();
dPoint3Dsss.Add(new DPoint3d(0, 0, 0));
dPoint3Dsss.Add(new DPoint3d(-10000, 10000, 0));
dPoint3Dsss.Add(new DPoint3d(-20000, 60000, 0));
dPoint3Dsss.Add(new DPoint3d(-40000, -10000, 0));
dPoint3Dsss.Add(new DPoint3d(-70000, 20000, 0));
dPoint3Dsss.Add(new DPoint3d(-90000, -40000, 0));
//生成线串,转化为element,并添加到model中
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Dsss);
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element.AddToModel();
//准备个空列表,接收函数返回的线串的点列表
List<DPoint3d> resPointList = new List<DPoint3d>();
curvePrimitive.TryGetLineString(resPointList);
// 判断返回的列表和原始生成线串的列表是否一致,
if (resPointList.SequenceEqual(dPoint3Dsss))
{
MessageBox.Show("get a same point list with the orogin list");
}
else
{
MessageBox.Show("they are different list");
}
}
TryGetLineStringPointCount ()
功能说明:返回线串类型曲线的点个数;如果不是线串类型,则会返回0
代码示例:
public static void CurvePrimitiveExample_TryGetLineStringPointCount()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<DPoint3d> dPoint3Dsss = new List<DPoint3d>();
dPoint3Dsss.Add(new DPoint3d(0, 0, 0));
dPoint3Dsss.Add(new DPoint3d(-10000, 10000, 0));
dPoint3Dsss.Add(new DPoint3d(-20000, 60000, 0));
dPoint3Dsss.Add(new DPoint3d(-40000, -10000, 0));
dPoint3Dsss.Add(new DPoint3d(-70000, 20000, 0));
dPoint3Dsss.Add(new DPoint3d(-90000, -40000, 0));
//生成线串,转化为element,并添加到model中
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Dsss);
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element.AddToModel();
curvePrimitive.TryGetLineStringPointCount(out int count);
MessageBox.Show("the count of this lineString's point is " + count.ToString());
}
TryGetPointInLineString ()
功能说明:返回线串中某个索引处的点
代码示例:
TryGetSegmentInLineString ()
功能说明:
代码示例:
WireCentroid ()
功能说明:获取两个fraction之间对应曲线的长度和这段曲线的中点
代码示例:
public static void CurvePrimitiveExample_WireCentroid()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用CreateLineString方法创建线串类型的CurvePrimitive,将线串转化为元素添加到model中
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLineString(dPoint3Ds);
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element.AddToModel();
// 求出基本曲线上给定位置(曲线终点处)处的位置信息
curvePrimitive.Length(out double curveLength);
CurveLocationDetail curveLocationDetail0 = curvePrimitive.PointAtSignedDistanceFromFraction(0.0, curveLength/4, false);
CurveLocationDetail curveLocationDetail1 = curvePrimitive.PointAtSignedDistanceFromFraction(0.0, curveLength / 2, false);
//获取1/4 和1/2处对应的fraction
double fraction1 = curveLocationDetail0.Fraction;
double fraction2 = curveLocationDetail1.Fraction;
//使用WireCentroid方法获取1/4 和1/2之间曲线的长度和这段对应的中点
curvePrimitive.WireCentroid(out double sectionLength, out DPoint3d sectionPoint, fraction1, fraction2);
//创建一个新的点列表,将1/4 和1/2处对应的点的和这段的终点添加到空的点列表中
List<DPoint3d> dPoint3Dss = new List<DPoint3d>();
dPoint3Dss.Add(curveLocationDetail0.Point);
dPoint3Dss.Add(sectionPoint);
dPoint3Dss.Add(curveLocationDetail1.Point);
//利用上一步骤的点列表创建新的线串,转化为element,并添加到model中
CurvePrimitive curvePrimitive1 = CurvePrimitive.CreateLineString(dPoint3Dss);
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitive1, null);
element1.AddToModel();
//在消息框中显示1/4 和1/2之间曲线的长度和本段长度占曲线总长的比例
MessageBox.Show("section length is " + sectionLength.ToString() +
" \n\r that is "+(sectionLength/curveLength).ToString() + "for the total curve length");
}
属性:
IsExtensibleFractionSpace { get; }
IsMappableFractionSpace { get; }
功能说明:对于任意的CurvePrimitive,都可以访问这两个只读属性来获得曲线的属性
代码示例:
public static void CurvePrimitiveExample_CreateArc()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
DEllipse3d dEllipse3D = new DEllipse3d(0 * UorPerMas, 5 * UorPerMas, 0 * UorPerMas, 10 * UorPerMas, 10 * UorPerMas, 0 * UorPerMas); //创建DEllipse3d
CurvePrimitive curvePrimitive = CurvePrimitive.CreateArc(dEllipse3D);// 使用CurvePrimitive下的静态方法CreateArc
//CurvePrimitive的两个属性
bool m_IsExtenSilbleFractionSpace = curvePrimitive.IsExtensibleFractionSpace;
bool m_IsMappableFractionSpace = curvePrimitive.IsMappableFractionSpace;
//将CurvePrimitive转为Element, 持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitive, null);
element.AddToModel();
}
1.1.1.1 BsplineCurve
说明:BsplineCurve类继承自CurvePrimitive类,并实现了IBsplineCurve, IBsplineCurveConstruction接口,类中有B样条曲线相关的方法和属性等信息
构造器:
功能说明:创建空的B样条曲线对象,曲线的控点后期可以通过AddControlPoint()方法添加;曲线必须在经过Validate()方法后才能使用
代码示例:
public void BsplineCurveTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
Bentley.GeometryNET.BsplineCurve bsplineCurve11 = Bentley.GeometryNET.BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve11, null);
element.AddToModel();
//创建一个空的B样条曲线,坐标后期可以使用AddControlPoint()添加,直到Validate()函数之后,曲线才能使用
Bentley.GeometryNET.BsplineCurve res = new Bentley.GeometryNET.BsplineCurve();
res.AddControlPoint(dPoint3Ds[0]);
res.AddControlPoint(dPoint3Ds[1]);
res.AddControlPoint(dPoint3Ds[2]);
res.AddControlPoint(dPoint3Ds[3]);
res.AddControlPoint(dPoint3Ds[4]);
res.AddControlPoint(dPoint3Ds[5]);
res.AddControlPoint(dPoint3Ds[6]);
res.SetOrder(3);
res.ValidateConstruction();
Element element1 = DraftingElementSchema.ToElement(dgnModel, res, null);
element1.AddToModel();
}
方法:
AddControlPoint(DPoint3d controlPoint);
功能说明:为空的B样条曲线添加控制点
代码示例:
public void AddControlPointTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建一个空的B样条曲线,使用AddControlPoint()添加点,直到Validate()函数之后,曲线才能使用
Bentley.GeometryNET.BsplineCurve res = new Bentley.GeometryNET.BsplineCurve();
res.AddControlPoint(dPoint3Ds[0]);
res.AddControlPoint(dPoint3Ds[1]);
res.AddControlPoint(dPoint3Ds[2]);
res.AddControlPoint(dPoint3Ds[3]);
res.AddControlPoint(dPoint3Ds[4]);
res.AddControlPoint(dPoint3Ds[5]);
res.AddControlPoint(dPoint3Ds[6]);
res.SetOrder(3);
res.ValidateConstruction();
//ValidateConstruction执行之后,将曲线转化为element,添加到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, res, null);
element1.AddToModel();
}
AddKnot(double knot);
功能说明:为B样条曲线添加分段点
代码示例:
public void AddKnotTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
//为创建的B样条曲线添加分段点,将新的曲线转化为element并添加到model中
var res = bsplineCurve.AddKnot(0.1);
Element element1 = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element1.AddToModel();
}
AddWeight(double weight);
功能说明:为B样条曲线添加weight
代码示例:
public void AddWeightTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
//使用addweight方法为样条曲线添加weight,然后将其转为element,并添加到model中
var res = bsplineCurve.AddWeight(0.2);
Element element1 = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element1.AddToModel();
}
ControlPoints();
功能说明:获取B样条曲线的控制点
代码示例:
public void ControlPointsTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
//使用ControlPoints方法获取样条曲线的控制点,将控制点生成线串,然后将其转为element,并添加到model中
var res = bsplineCurve.ControlPoints();
LineString lineString = new LineString(res);
Element element1 = DraftingElementSchema.ToElement(dgnModel, lineString, null);
element1.AddToModel();
}
CreateFromPoles(IList
功能说明:从关键点创建B样条曲线
代码示例:
public void CreateFromPolesTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//CreateFromPoles 重载1, 点列表和曲线阶数
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
}
CreateFromPoles(IList
功能说明:从关键点创建B样条曲线
代码示例:
public void CreateFromPolesTest2()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//CreateFromPoles 重载2, 点列表和曲线阶数,是否闭合
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3,true);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
}
CreateFromPoles(IList
功能说明:从关键点创建B样条曲线
代码示例:
public void CreateFromPolesTest3()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
List<double> knot = new List<double>() { 0.1,0.6,0.8};
//CreateFromPoles 重载3, 点列表和曲线阶数,是否闭合,曲线分段的区间
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, knot, 3,false);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
}
CreateFromPoles(IList
功能说明:从关键点创建B样条曲线
代码示例:
public void CreateFromPolesTest4()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
List<double> knot = new List<double>() { 0.1, 0.6, 0.8 };
List<double> weight = new List<double>() { 0.1, 0.6, 0.8 };
//CreateFromPoles 重载4, 点列表和曲线阶数,是否闭合,曲线分段的区间,曲线weight值和是否应用该值
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, knot, weight, 3,true,false);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
}
DispatchToDDHandler(AbstractDDHandler handler);
功能说明:
代码示例:
GetClosed();
功能说明:判断B仰天曲线是否比闭合
代码示例:
public void GetClosedTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
//判断B样条是否闭合,返回值为bool类型,将结果显示在消息框中
bool res = bsplineCurve.GetClosed();
MessageBox.Show("the result is " + res.ToString());
}
GetControlPointCount();
功能说明:获取B样条曲线控制点的个数
代码示例:
public void GetControlPointCountTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
//使用方法获取B样条曲线的控制点个数,并用消息框显示出来
int ptNumbers = bsplineCurve.GetControlPointCount();
MessageBox.Show("the control points number of this bsplineCurve is " + ptNumbers.ToString());
}
GetKnotCount();
功能说明:获取B样条曲线分段点的个数
代码示例:
public void GetControlPointCountTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
//使用方法获取B样条曲线的控制点个数,并用消息框显示出来
int ptNumbers = bsplineCurve.GetControlPointCount();
MessageBox.Show("the control points number of this bsplineCurve is " + ptNumbers.ToString());
}
GetOrder();
功能说明:获取B样条曲线的阶数
代码示例:
public void GetOrderTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
//使用方法获取B样条曲线的阶数,并用消息框显示出来
var numbers = bsplineCurve.GetOrder();
MessageBox.Show("the order of this bsplineCurve is " + numbers.ToString());
}
GetWeightCount();
功能说明:获取B样条曲线weight的个数
代码示例:
public void GetWeightCountTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
////使用方法获取B样条曲线的weight count,并用消息框显示出来
int numbers = bsplineCurve.GetWeightCount();
MessageBox.Show("the weight count of this bsplineCurve is " + numbers.ToString());
}
Knots();
功能说明:获取B样条曲线的分段点knots
代码示例:
public void KnotsTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
//使用方法获取B样条曲线的分段信息
var knots = bsplineCurve.Knots();
MessageBox.Show("the knots of this bsplineCurve is " + knots.ToString());
}
SetClosed(bool closed);
功能说明:将B样条曲线设置为闭合
代码示例:
public void SetClosedTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
//将B样条设为闭合,返回值为bool类型,将结果转化为element,并添加到model中
bool res = bsplineCurve.SetClosed(true);
Element element1 = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element1.AddToModel();
}
SetOrder(int order);
功能说明:设置B样条曲线的阶数
代码示例:
public void SetOrderTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
//SetOrder 方法将样条曲线的阶数设置为4,新的曲线转为element,添加到model中
bool res = bsplineCurve.SetOrder(4);
Element element1 = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element1.AddToModel();
}
ValidateConstruction();
功能说明:用构造器创建的空的B样条曲线经过ValidateConstruction()方法后才能使用
代码示例:
public void ValidateConstructionTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建一个空的B样条曲线,使用AddControlPoint()添加点,直到Validate()函数之后,曲线才能使用
Bentley.GeometryNET.BsplineCurve res = new Bentley.GeometryNET.BsplineCurve();
res.AddControlPoint(dPoint3Ds[0]);
res.AddControlPoint(dPoint3Ds[1]);
res.AddControlPoint(dPoint3Ds[2]);
res.AddControlPoint(dPoint3Ds[3]);
res.AddControlPoint(dPoint3Ds[4]);
res.AddControlPoint(dPoint3Ds[5]);
res.AddControlPoint(dPoint3Ds[6]);
res.SetOrder(3);
res.ValidateConstruction();
//ValidateConstruction执行之后,将曲线转化为element,添加到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, res, null);
element1.AddToModel();
}
Weights();
功能说明:获取B样条曲线的weight信息
代码示例:
public void WeightsTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
var res = bsplineCurve.Weights();
MessageBox.Show("this bsplineCurve's weight is " + res.ToString());
}
属性:
AsIGeometry { get; }
功能说明:获取B样条曲线的类型信息
代码示例:
public void AsIGeometryTest1()
{
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, -20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, 40000, 0));
//创建B样条曲线,转化为element,并添加到model中
BsplineCurve bsplineCurve = BsplineCurve.CreateFromPoles(dPoint3Ds, 3);
Element element = DraftingElementSchema.ToElement(dgnModel, bsplineCurve, null);
element.AddToModel();
var res = bsplineCurve.AsIGeometry;
MessageBox.Show(res.ToString());
}
1.1.1.2 ParametricCurve
说明:ParametricCurve类继承于CurvePrimitive类,有CurvePrimitive类的方法和属性
构造器:
ParametricCurve()
功能说明:ParametricCurve的构造函数,创建一个新的ParametricCurve对象
代码示例:
方法:
无
属性:
AsLineString {get;}
功能说明:
代码示例:
AsEllipticArc {get;}
功能说明:
代码示例:
AsCircularArc {get;}
功能说明:
代码示例:
AsLineSegment {get;}
功能说明:
代码示例:
AsIParametricCurve {get;}
功能说明:
代码示例:
1.1.1.2.1 CircularArc
说明:继承于ParametricCurve类
构造器:
CircularArc()
功能说明:CircularArc类的构造函数,创建一个新的CircularArc对象,该函数有两个重载
代码示例:
public void CircularArcTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个dEllipse3D对象
DEllipse3d dEllipse3D = new DEllipse3d(0 * UorPerMas, 5 * UorPerMas, 0 * UorPerMas, 10 * UorPerMas, 10 * UorPerMas, 0 * UorPerMas); //创建DEllipse3d
// 使用入参为dEllipse3D的构造函数重载
Bentley.GeometryNET.CircularArc circularArc = new Bentley.GeometryNET.CircularArc(dEllipse3D);
//转为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, circularArc, null);
element.AddToModel();
}
public void CircularArcTest2()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个dEllipse3D对象
DEllipse3d dEllipse3D = new DEllipse3d(0 * UorPerMas, 5 * UorPerMas, 0 * UorPerMas, 10 * UorPerMas, 10 * UorPerMas, 0 * UorPerMas); //创建DEllipse3d
// 使用入参为dEllipse3D的构造函数重载
Bentley.GeometryNET.CircularArc circularArc = new Bentley.GeometryNET.CircularArc(dEllipse3D);
// 使用入参为circularArc类型的构造函数重载
Bentley.GeometryNET.CircularArc circularArc1 = new Bentley.GeometryNET.CircularArc(circularArc);
//转为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, circularArc1, null);
element.AddToModel();
}
方法:
属性:
1.1.1.2.2 EllipticArc
说明:
方法:
属性:
1.1.1.2.3 LineSegment
说明:
方法:
属性:
1.1.1.2.4 LineString
说明:
方法:
属性:
1.1.1.3 TransitionSpiral
说明:
方法:
属性:
1.2 AnyGroup
说明:各种IxxxGroup继承的最小接口,其中每个xxx都是一个约束类型。
方法:
属性:
1.2.1 GeometryGroup
说明:几何组,继承自AnyGroup类
方法:
属性:
1.3 AnyPoint
说明:
方法:
属性:
1.3.1 AnySinglePoint
说明:
方法:
属性:
1.3.1.1 Coordinate
说明:
方法:
属性:
1.4 AnySolid
说明:作为ISolidGroup的最小接口
构造函数:
方法:
属性:
1.4.1 AnyAnalyticSolid
说明:
方法:
属性:
1.4.2 SolidPrimitive
说明:solid体的几何原型
构造器:
SolidPrimitive()
功能说明:新建空的solid primitive对象
代码示例:
public void SolidPrimitiveTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建一个圆台
DgnConeDetail dgnConeDetail = new DgnConeDetail(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitZ, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//使用SolidPrimitive的静态方法创建圆台
Bentley.GeometryNET.SolidPrimitive solidPrimitive = Bentley.GeometryNET.SolidPrimitive.CreateDgnCone(dgnConeDetail);
//新建一个空的solid primitive 对象
Bentley.GeometryNET.SolidPrimitive solidPrimitive1 = new Bentley.GeometryNET.SolidPrimitive();
solidPrimitive1 = solidPrimitive;
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, solidPrimitive, null);
element.AddToModel();
Element element1 = DraftingElementSchema.ToElement(dgnModel, solidPrimitive1, null);
element1.AddToModel();
}
方法:
ComputeSecondMomentAreaProducts()
功能说明:返回面积、质心、方向和主要力矩等信息,计算时将其视为一个壳
代码示例:
public void ComputeSecondMomentAreaProductsTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建一个圆台
DgnConeDetail dgnConeDetail = new DgnConeDetail(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitZ, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//使用SolidPrimitive的静态方法创建圆台
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnCone(dgnConeDetail);
//该方法返回solid 的 面积、质心、方向和主要力矩等信息
bool res = solidPrimitive.ComputeSecondMomentAreaProducts(out DMatrix4d dMatrix4D);
//将矩阵的第一个值打印出来
dMatrix4D.Get(out double c00, out double c01, out double c02, out double c03, out double c10, out double c11, out double c12, out double c13, out double c20, out double c21, out double c22, out double c23, out double c30, out double c31, out double c32, out double c33);
System.Windows.Forms.MessageBox.Show(c00.ToString());
}
CreateDgnBox()
功能说明:创建dgnBox
代码示例:
public void CreateDgnBoxTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建dgnBox
DgnBoxDetail dgnBoxDetail = new DgnBoxDetail(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, UorPerMas, UorPerMas, UorPerMas, true);
//使用静态函数创建SolidPrimitive
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnBox(dgnBoxDetail);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, solidPrimitive, null);
element.AddToModel();
}
CreateDgnCone()
功能说明:创建圆台
代码示例:
public void CreateDgnConeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建一个圆台
DgnConeDetail dgnConeDetail = new DgnConeDetail(dPoint3DA, dPoint3DB,DVector3d.UnitX,DVector3d.UnitZ,1.0*UorPerMas,0.8*UorPerMas,false);
//使用SolidPrimitive的静态方法创建圆台
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnCone(dgnConeDetail);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, solidPrimitive, null);
element.AddToModel();
}
CreateDgnExtrusion()
功能说明:创建拉伸体
代码示例:
public void CreateDgnExtrusionTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//新建一个DgnExtrusionDetail
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Open, false);
DgnExtrusionDetail dgnExtrusionDetail = new DgnExtrusionDetail(curvePrimitives, DVector3d.UnitY, true);
// 使用静态方法创建拉伸体
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnExtrusion(dgnExtrusionDetail);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, solidPrimitive, null);
element.AddToModel();
}
CreateDgnRotationalSweep()
功能说明:创建dgn旋转体 DgnRotationalSweep
代码示例:
public void CreateDgnRotationalSweepTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建圆作为旋转体的端面,指定旋转体的旋转轴
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Inner);
DRay3d dRay3D = new DRay3d(DPoint3d.Zero, DVector3d.UnitZ);
//新建dgn旋转体信息
DgnRotationalSweepDetail dgnRotationalSweepDetail = new DgnRotationalSweepDetail(curvePrimitives, dRay3D,Angle.TWOPI, true);
//使用静态方法新建SolidPrimitive
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnRotationalSweep(dgnRotationalSweepDetail);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, solidPrimitive, null);
element.AddToModel();
}
CreateDgnRuledSweep ()
功能说明:创建有规则的扫掠体
代码示例:
public void CreateDgnRuledSweepTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<CurveVector> curvePrimitives = new List<CurveVector>();
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
List<DPoint3d> dPoint3Ds0 = new List<DPoint3d>();
List<DPoint3d> dPoint3Ds1 = new List<DPoint3d>();
List<DPoint3d> dPoint3Ds2 = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds0.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds0.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds1.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds1.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds2.Add(new DPoint3d(90000, -40000, 0));
dPoint3Ds2.Add(new DPoint3d(100000, 40000, 0));
//创建CurveVector列表
CurveVector curvePrimitive = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Open, false);
CurveVector curvePrimitive0 = CurveVector.CreateLinear(dPoint3Ds0, CurveVector.BoundaryType.Open, false);
CurveVector curvePrimitive1 = CurveVector.CreateLinear(dPoint3Ds1, CurveVector.BoundaryType.Open, false);
CurveVector curvePrimitive2 = CurveVector.CreateLinear(dPoint3Ds2, CurveVector.BoundaryType.Open, false);
curvePrimitives.Add(curvePrimitive);
curvePrimitives.Add(curvePrimitive0);
curvePrimitives.Add(curvePrimitive1);
curvePrimitives.Add(curvePrimitive2);
//创建规则拉伸体信息 DgnRuledSweepDetail
DgnRuledSweepDetail dgnRuledSweepDetail = new DgnRuledSweepDetail(curvePrimitives, true);
// 使用静态函数创建solidPrimitive
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnRuledSweep(dgnRuledSweepDetail);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, solidPrimitive, null);
element.AddToModel();
}
CreateDgnSphere ()
功能说明:新建圆柱体
代码示例:
public void CreateDgnSphereTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个dgn圆柱体
DgnSphereDetail dgnSphereDetail = new DgnSphereDetail(DPoint3d.Zero, UorPerMas);
// 使用静态方法新建一个 圆柱体
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnSphere(dgnSphereDetail);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, solidPrimitive, null);
element.AddToModel();
}
CreateDgnTorusPipe ()
功能说明:新建dgn环管体
代码示例:
public void CreateDgnTorusPipeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建dgn环管
DgnTorusPipeDetail dgnTorusPipeDetail = new DgnTorusPipeDetail(DPoint3d.Zero, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, 0.5 * UorPerMas, 180, true);
//使用静态方法创建环管solid
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnTorusPipe(dgnTorusPipeDetail);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, solidPrimitive, null);
element.AddToModel();
}
CreateFromNative ()
功能说明:从本地指针创建solid primitive
代码示例:
public void CreateFromNativeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建dgn环管
DgnTorusPipeDetail dgnTorusPipeDetail = new DgnTorusPipeDetail(DPoint3d.Zero, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, 0.5 * UorPerMas, 180, true);
//使用静态方法创建环管solid
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnTorusPipe(dgnTorusPipeDetail);
// 获取指针值
IntPtr intPtr = SolidPrimitive.DereferenceToNative(solidPrimitive, true);
// 使用指针创建一个solid primitive
SolidPrimitive solidPrimitive0 = SolidPrimitive.CreateFromNative(intPtr);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, solidPrimitive0, null);
element.AddToModel();
}
CreateStrongTypeFromNativeISolidPrimitive ()
功能说明:从指针创建强类型几何
代码示例:
public void CreateStrongTypeFromNativeISolidPrimitiveTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建dgn环管
DgnTorusPipeDetail dgnTorusPipeDetail = new DgnTorusPipeDetail(DPoint3d.Zero, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, 0.5 * UorPerMas, 180, true);
//使用静态方法创建环管solid
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnTorusPipe(dgnTorusPipeDetail);
// 获取指针值
IntPtr intPtr = SolidPrimitive.DereferenceToNative(solidPrimitive, true);
//从指针创建新的几何
AnyGeometry solidPrimitive0 = SolidPrimitive.CreateStrongTypeFromNativeIGeometry(intPtr, CreateAction.Capture);
//将几何转为element 并添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, solidPrimitive0 as SolidPrimitive, null);
element.AddToModel();
}
DereferenceToNative ()
功能说明:获取solid primitive对象的指针
代码示例:
public void DereferenceToNativeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建dgn环管
DgnTorusPipeDetail dgnTorusPipeDetail = new DgnTorusPipeDetail(DPoint3d.Zero, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, 0.5 * UorPerMas, 180, true);
//使用静态方法创建环管solid
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnTorusPipe(dgnTorusPipeDetail);
// 获取指针值
IntPtr intPtr = SolidPrimitive.DereferenceToNative(solidPrimitive, true);
System.Windows.Forms.MessageBox.Show("the intPtr of this solid primitive is " + intPtr.ToString());
}
Dispose()
功能说明:
代码示例:
IsSameStructure ()
功能说明:判断solid primitive是否为相同结构
代码示例:
public void IsSameStructureTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建一个圆台
DgnConeDetail dgnConeDetail = new DgnConeDetail(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitZ, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//使用SolidPrimitive的静态方法创建圆台
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnCone(dgnConeDetail);
//创建dgnBox
DgnBoxDetail dgnBoxDetail = new DgnBoxDetail(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, UorPerMas, UorPerMas, UorPerMas, true);
//使用静态函数创建SolidPrimitive
SolidPrimitive solidPrimitive0 = SolidPrimitive.CreateDgnBox(dgnBoxDetail);
//比较两个solid primitive是否为相同结构
bool res = solidPrimitive.IsSameStructure(solidPrimitive0);
System.Windows.Forms.MessageBox.Show("they are same structure? " + res.ToString());
}
IsSameStructureAndGeometry ()
功能说明:判断两个solid primitive对象是否为相同的结构和几何
代码示例:
public void IsSameStructureAndGeometryTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
DPoint3d dPoint3DBB = new DPoint3d(0, 0, 2 * UorPerMas);
//创建一个圆台
DgnConeDetail dgnConeDetail = new DgnConeDetail(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitZ, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//使用SolidPrimitive的静态方法创建圆台
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnCone(dgnConeDetail);
//创建一个圆台
DgnConeDetail dgnConeDetail0 = new DgnConeDetail(dPoint3DA, dPoint3DBB, DVector3d.UnitX, DVector3d.UnitZ, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//使用SolidPrimitive的静态方法创建圆台
SolidPrimitive solidPrimitive0 = SolidPrimitive.CreateDgnCone(dgnConeDetail0);
// 判断是否为相同结构和几何
bool res = solidPrimitive.IsSameStructureAndGeometry(solidPrimitive0, 0.01 * UorPerMas);
bool ressss = solidPrimitive.IsSameStructure(solidPrimitive0);
System.Windows.Forms.MessageBox.Show("they are same structure? " + ressss.ToString()+"\n\r"+
"they are same geometry? "+ res.ToString());
TryGetConstructiveFrame ()
功能说明:获取局部坐标系统的转换,这是构建该实体的典型方法。
代码示例:
public void TryGetConstructiveFrameTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
DPoint3d dPoint3DBB = new DPoint3d(0, 0, 2 * UorPerMas);
//创建一个圆台
DgnConeDetail dgnConeDetail = new DgnConeDetail(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitZ, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//使用SolidPrimitive的静态方法创建圆台
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnCone(dgnConeDetail);
// 获取 solid primitive的 Constructive Frame
bool res = solidPrimitive.TryGetConstructiveFrame(out DTransform3d loaclToWorld, out DTransform3d worldToLocal);
if (res)
{
System.Windows.Forms.MessageBox.Show("get the Constructive Frame successfully");
}
else
{
System.Windows.Forms.MessageBox.Show("get the Constructive Frame failed");
}
}
TryGetDgnBoxDetail ()
功能说明:如果这是SolidPrimitive的DgnBox变体,则返回其详细数据的(副本)。对于任何其他变体,返回nullptr
代码示例:
public void TryGetDgnBoxDetailTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建dgnBox
DgnBoxDetail dgnBoxDetail = new DgnBoxDetail(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, UorPerMas, UorPerMas, UorPerMas, true);
//使用静态函数创建SolidPrimitive
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnBox(dgnBoxDetail);
DgnBoxDetail res = solidPrimitive.TryGetDgnBoxDetail();
System.Windows.Forms.MessageBox.Show("the box detail topX is " +res.TopX.ToString()+
"\n\r the box detail topY is "+res.TopY.ToString()+
"\n\r the box detail baseX is " + res.BaseX.ToString() +
"\n\r the box detail baseY is " + res.BaseY.ToString());
}
TryGetDgnConeDetail ()
功能说明:如果这是SolidPrimitive的DgnCone变体,返回它的详细数据的(副本)。对于任何其他变体,返回nullptr
代码示例:
public void TryGetDgnConeDetailTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建一个圆台
DgnConeDetail dgnConeDetail = new DgnConeDetail(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitZ, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//使用SolidPrimitive的静态方法创建圆台
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnCone(dgnConeDetail);
DgnConeDetail res = solidPrimitive.TryGetDgnConeDetail();
if (res != null)
{
System.Windows.Forms.MessageBox.Show("have get the DgnConeDetail successfully");
}
}
TryGetDgnExtrusionDetail ()
功能说明:如果这是SolidPrimitive的DgnExtrusion变体,则返回其详细数据的(副本)。对于任何其他变体,返回nullptr
代码示例:
public void TryGetDgnExtrusionDetailTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//新建一个DgnExtrusionDetail
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Open, false);
DgnExtrusionDetail dgnExtrusionDetail = new DgnExtrusionDetail(curvePrimitives, DVector3d.UnitY, true);
// 使用静态方法创建拉伸体
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnExtrusion(dgnExtrusionDetail);
DgnExtrusionDetail res = solidPrimitive.TryGetDgnExtrusionDetail();
if (res != null)
{
System.Windows.Forms.MessageBox.Show("have get the DgnExtrusionDetail successfully");
}
}
TryGetDgnRotationalSweepDetail ()
功能说明:如果这是SolidPrimitive的DgnRotationalSweep变体,返回它的详细数据的(副本)。对于任何其他变体,返回nullptr
代码示例:
public void TryGetDgnRotationalSweepDetailTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建圆作为旋转体的端面,指定旋转体的旋转轴
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Inner);
DRay3d dRay3D = new DRay3d(DPoint3d.Zero, DVector3d.UnitZ);
//新建dgn旋转体信息
DgnRotationalSweepDetail dgnRotationalSweepDetail = new DgnRotationalSweepDetail(curvePrimitives, dRay3D, Angle.TWOPI, true);
//使用静态方法新建SolidPrimitive
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnRotationalSweep(dgnRotationalSweepDetail);
DgnRotationalSweepDetail res = solidPrimitive.TryGetDgnRotationalSweepDetail();
if (res != null)
{
System.Windows.Forms.MessageBox.Show("have get the DgnRotationalSweepDetail successfully");
}
}
TryGetDgnRuledSweepDetail ()
功能说明:如果这是SolidPrimitive的DgnRuledSweep变体,则返回其详细数据的(副本)。对于任何其他变体,返回nullptr
代码示例:
public void TryGetDgnRuledSweepDetailTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<CurveVector> curvePrimitives = new List<CurveVector>();
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
List<DPoint3d> dPoint3Ds0 = new List<DPoint3d>();
List<DPoint3d> dPoint3Ds1 = new List<DPoint3d>();
List<DPoint3d> dPoint3Ds2 = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds0.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds0.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds1.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds1.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds2.Add(new DPoint3d(90000, -40000, 0));
dPoint3Ds2.Add(new DPoint3d(100000, 40000, 0));
//创建CurveVector列表
CurveVector curvePrimitive = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Open, false);
CurveVector curvePrimitive0 = CurveVector.CreateLinear(dPoint3Ds0, CurveVector.BoundaryType.Open, false);
CurveVector curvePrimitive1 = CurveVector.CreateLinear(dPoint3Ds1, CurveVector.BoundaryType.Open, false);
CurveVector curvePrimitive2 = CurveVector.CreateLinear(dPoint3Ds2, CurveVector.BoundaryType.Open, false);
curvePrimitives.Add(curvePrimitive);
curvePrimitives.Add(curvePrimitive0);
curvePrimitives.Add(curvePrimitive1);
curvePrimitives.Add(curvePrimitive2);
//创建规则拉伸体信息 DgnRuledSweepDetail
DgnRuledSweepDetail dgnRuledSweepDetail = new DgnRuledSweepDetail(curvePrimitives, true);
// 使用静态函数创建solidPrimitive
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnRuledSweep(dgnRuledSweepDetail);
DgnRuledSweepDetail res = solidPrimitive.TryGetDgnRuledSweepDetail();
if (res != null)
{
System.Windows.Forms.MessageBox.Show("have get the DgnRuledSweepDetail successfully");
}
}
TryGetDgnSphereDetail ()
功能说明:如果这是SolidPrimitive的DgnSphere变体,则返回其详细数据的(副本)。对于任何其他变体,返回nullptr
代码示例:
public void TryGetDgnSphereDetailTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个dgn圆柱体
DgnSphereDetail dgnSphereDetail = new DgnSphereDetail(DPoint3d.Zero, UorPerMas);
// 使用静态方法新建一个 圆柱体
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnSphere(dgnSphereDetail);
DgnSphereDetail res = solidPrimitive.TryGetDgnSphereDetail();
if (res != null)
{
System.Windows.Forms.MessageBox.Show("have get the DgnRuledSweepDetail successfully");
}
}
TryGetDgnTorusPipeDetail ()
功能说明:如果这是SolidPrimitive的DgnTorusPipe变体,返回它的详细数据的(副本)。对于任何其他变体,返回nullptr
代码示例:
public void TryGetDgnTorusPipeDetailTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建dgn环管
DgnTorusPipeDetail dgnTorusPipeDetail = new DgnTorusPipeDetail(DPoint3d.Zero, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, 0.5 * UorPerMas, 180, true);
//使用静态方法创建环管solid
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnTorusPipe(dgnTorusPipeDetail);
DgnTorusPipeDetail res = solidPrimitive.TryGetDgnTorusPipeDetail();
if (res != null)
{
System.Windows.Forms.MessageBox.Show("have get the DgnRuledSweepDetail successfully");
}
}
TryGetRange()
功能说明:计算并返回solid primitive的范围。
代码示例:
public void TryGetRangeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建dgn环管
DgnTorusPipeDetail dgnTorusPipeDetail = new DgnTorusPipeDetail(DPoint3d.Zero, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, 0.5 * UorPerMas, 180, true);
//使用静态方法创建环管solid
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnTorusPipe(dgnTorusPipeDetail);
//获取该solid primitive的 range信息
bool res = solidPrimitive.TryGetRange(out DRange3d dRange3D);
//将此range的 Low High作为顶点生成线段,并添加到model中
DSegment3d dSegment3D = new DSegment3d(dRange3D.Low, dRange3D.High);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
属性:
IsStrongSolidType { get; }
功能说明:solid primitive是否为StrongSolidType的属性
代码示例:
public void IsStrongSolidTypeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建一个圆台
DgnConeDetail dgnConeDetail = new DgnConeDetail(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitZ, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//使用SolidPrimitive的静态方法创建圆台
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnCone(dgnConeDetail);
bool res = solidPrimitive.IsStrongSolidType;
System.Windows.Forms.MessageBox.Show("is this solid primitive a StrongSolidType? "+ res.ToString());
}
PrimitiveType { get; }
功能说明:solid 类型的属性信息,类型包括以下几种:
None = 0,
DgnTorusPipe = 1,
DgnCone = 2,
DgnBox = 3,
DgnSphere = 4,
DgnExtrusion = 5,
DgnRotationalSweep = 6,
DgnRuledSweep = 7
代码示例:
public void PrimitiveTypeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建一个圆台
DgnConeDetail dgnConeDetail = new DgnConeDetail(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitZ, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//使用SolidPrimitive的静态方法创建圆台
SolidPrimitive solidPrimitive = SolidPrimitive.CreateDgnCone(dgnConeDetail);
SolidPrimitiveType res = solidPrimitive.PrimitiveType;
System.Windows.Forms.MessageBox.Show("this solid primitive's type is " + res.ToString());
/*
None = 0,
DgnTorusPipe = 1,
DgnCone = 2,
DgnBox = 3,
DgnSphere = 4,
DgnExtrusion = 5,
DgnRotationalSweep = 6,
DgnRuledSweep = 7
*/
}
1.4.2.1 CircularCone
说明:
方法:
属性:
1.4.2.2 CircularCylinder
说明:
方法:
属性:
1.4.2.3 SkewedCone
说明:
方法:
属性:
1.4.2.4 StronglyTypedSolidPrimitive
说明:派生自SolidPrimitive的强类型实体基元的中间类
方法:
构造函数:
属性:
1.4.2.4.1 Block
说明:强类型,兼容CommonGeoemtry的Block.
构造函数:
Block()
功能说明:
代码示例:
Block(IPlacement, DPoint3d, DPoint3d, Boolean)
功能说明:
代码示例:
方法:
DispatchToDDHandler()
功能说明:
代码示例:
GetBlock()
功能说明:
代码示例:
属性:
AsIGeometry { get; }
功能说明:
代码示例:
1.4.2.4.2 DgnBox
说明:强类型、兼容CommonGeoemtry的DgnBox。
构造函数:
DgnBox(DPoint3d baseOrigin, DPoint3d topOrigin, DVector3d vectorX, DVector3d vectorY, double baseX, double baseY, double topX, double topY, bool capped);
功能说明:构造函数,创建一个新的dgnBox对象
代码示例:
public void DgnBoxTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建dgnBox
Bentley.GeometryNET.DgnBox dgnBox = new Bentley.GeometryNET.DgnBox(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, UorPerMas, UorPerMas, UorPerMas, true);
Element element = DraftingElementSchema.ToElement(dgnModel, dgnBox, null);
element.AddToModel();
}
方法:
DispatchToDDHandler ()
功能说明:
代码示例:
GetDgnBox ()
功能说明:获取dgnBox的各种信息
代码示例:
public void GetDgnBoxTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建dgnBox
Bentley.GeometryNET.DgnBox dgnBox = new Bentley.GeometryNET.DgnBox(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, UorPerMas, UorPerMas, UorPerMas, true);
// 获取dgnBox的各种信息
dgnBox.GetDgnBox(out DPoint3d baseOrigin, out DPoint3d topOrigin, out DVector3d vectorX, out DVector3d vectorY, out double baseX, out double baseY, out double topX, out double topY, out bool capped);
}
属性:
AsIGeometry { get; }
功能说明:
代码示例:
1.4.2.4.3 DgnCone
说明:强类型的DgnCone
构造函数:
DgnCone(DPoint3d, DPoint3d, Double, Double, Boolean)
功能说明:构造函数,创建一个新的dgnCone对象
代码示例:
public void DgnConeTest3()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建一个圆台
Bentley.GeometryNET.DgnCone dgnConeDetail = new Bentley.GeometryNET.DgnCone(dPoint3DA, dPoint3DB, DMatrix3d.Identity, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//将圆台转为element, 存到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnConeDetail, null);
element.AddToModel();
}
DgnCone(DPoint3d, DPoint3d, DMatrix3d, Double, Double, Boolean)
功能说明:构造函数,创建一个新的dgnCone对象
代码示例:
public void DgnConeTest2()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建一个圆台
Bentley.GeometryNET.DgnCone dgnConeDetail = new Bentley.GeometryNET.DgnCone(dPoint3DA, dPoint3DB, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//将圆台转为element, 存到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnConeDetail, null);
element.AddToModel();
}
DgnCone(DPoint3d, DPoint3d, DVector3d, DVector3d, Double, Double, Boolean)
功能说明:构造函数,创建一个新的dgnCone对象
代码示例:
public void DgnConeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建一个圆台
Bentley.GeometryNET.DgnCone dgnConeDetail = new Bentley.GeometryNET.DgnCone(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitZ, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//将圆台转为element, 存到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnConeDetail, null);
element.AddToModel();
}
方法:
DispatchToDDHandler ()
功能说明:
代码示例:
GetDgnCone ()
功能说明:获取dgnCone的信息
代码示例:
public void GetDgnConeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//准备生成圆台的顶 底中心点
DPoint3d dPoint3DA = new DPoint3d(0, 0, 0);
DPoint3d dPoint3DB = new DPoint3d(0, 0, 1 * UorPerMas);
//创建一个圆台
Bentley.GeometryNET.DgnCone dgnConeDetail = new Bentley.GeometryNET.DgnCone(dPoint3DA, dPoint3DB, DVector3d.UnitX, DVector3d.UnitZ, 1.0 * UorPerMas, 0.8 * UorPerMas, false);
//获取dgnCone的信息
dgnConeDetail.GetDgnCone(out DPoint3d centerA, out DPoint3d centerB, out DVector3d vectorX, out DVector3d vectorY, out double radiusA, out double radiusB, out bool capped);
//将圆台转为element, 存到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnConeDetail, null);
element.AddToModel();
}
属性:
AsIGeometry { get; }
功能说明:
代码示例:
1.4.2.4.4 DgnExtrusion
说明:强类型、兼容CommonGeoemtry的DgnExtrusion。
构造函数:
DgnExtrusion()
功能说明:拉伸体的构造函数
代码示例:
public void DgnExtrusionTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//新建一个DgnExtrusionDetail
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Open, false);
Bentley.GeometryNET.DgnExtrusion dgnExtrusionDetail = new Bentley.GeometryNET.DgnExtrusion(curvePrimitives, DVector3d.UnitY, true);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnExtrusionDetail, null);
element.AddToModel();
}
方法:
DispatchToDDHandler()
功能说明:
代码示例:
GetBaseGeometry()
功能说明:获取基本的拉伸几何
代码示例:
public void GetBaseGeometryTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//新建一个DgnExtrusionDetail
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Open, false);
Bentley.GeometryNET.DgnExtrusion dgnExtrusionDetail = new Bentley.GeometryNET.DgnExtrusion(curvePrimitives, DVector3d.UnitY, true);
// 获取拉伸的几何信息
Bentley.GeometryNET.Common.ISweepable sweepable = dgnExtrusionDetail.GetBaseGeometry();
if (sweepable != null)
{
System.Windows.Forms.MessageBox.Show("get the base geometry successfully");
}
}
GetCapped()
功能说明:获取DgnExtrusion是否闭合
代码示例:
public void GetCappedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//新建一个DgnExtrusionDetail
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Open, false);
Bentley.GeometryNET.DgnExtrusion dgnExtrusionDetail = new Bentley.GeometryNET.DgnExtrusion(curvePrimitives, DVector3d.UnitY, true);
// 获取DgnExtrusion 是否闭合,将结果打印出来
bool res = dgnExtrusionDetail.GetCapped();
System.Windows.Forms.MessageBox.Show("this DgnExtrusion is capped " + res.ToString());
}
GetExtrusionVector()
功能说明:获取拉伸向量
代码示例:
public void GetExtrusionVectorTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//新建一个DgnExtrusionDetail
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Open, false);
Bentley.GeometryNET.DgnExtrusion dgnExtrusionDetail = new Bentley.GeometryNET.DgnExtrusion(curvePrimitives, DVector3d.UnitY, true);
// 获取拉伸向量,将获取到的结果打印出来
DVector3d res = dgnExtrusionDetail.GetExtrusionVector();
if (res != null)
{
System.Windows.Forms.MessageBox.Show("get the ExtrusionVector successfully");
}
SetBaseGeometry()
功能说明:
代码示例:
SetCapped()
功能说明:设置闭合状态
代码示例:
public void SetCappedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//新建一个DgnExtrusionDetail
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Open, false);
Bentley.GeometryNET.DgnExtrusion dgnExtrusionDetail = new Bentley.GeometryNET.DgnExtrusion(curvePrimitives, DVector3d.UnitY, true);
//转为element 存到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnExtrusionDetail, null);
element.AddToModel();
//设置闭合为flase
dgnExtrusionDetail.SetCapped(false);
//将新的转为element,存到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, dgnExtrusionDetail, null);
element1.AddToModel();
}
SetExtrusionVector()
功能说明:设置拉伸向量
代码示例:
public void SetExtrusionVectorTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//新建一个DgnExtrusionDetail
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Open, false);
Bentley.GeometryNET.DgnExtrusion dgnExtrusionDetail = new Bentley.GeometryNET.DgnExtrusion(curvePrimitives, DVector3d.UnitY, true);
//转为element 存到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnExtrusionDetail, null);
element.AddToModel();
//设置闭合为flase
dgnExtrusionDetail.SetExtrusionVector(DVector3d.UnitZ);
//将新的转为element,存到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, dgnExtrusionDetail, null);
element1.AddToModel();
}
ValidateConstruction()
功能说明:
代码示例:
属性:
AsIGeometry { get; }
功能说明:
代码示例:
1.4.2.4.5 DgnRotationalSweep
说明:强类型、兼容CommonGeoemtry的DgnRotationalSweep。
构造函数:
DgnRotationalSweep()
功能说明:构造函数,创建一个新的DgnRotationalSweep对象
代码示例:
public void DgnRotationalSweepTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建圆作为旋转体的端面,指定旋转体的旋转轴
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Inner);
//新建dgn旋转体信息
Bentley.GeometryNET.DgnRotationalSweep dgnRotationalSweepDetail = new Bentley.GeometryNET.DgnRotationalSweep(curvePrimitives, DPoint3d.Zero, DVector3d.UnitZ, UorPerMas, true);
//转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element.AddToModel();
}
方法:
DispatchToDDHandler()
功能说明:
代码示例:
GetAxis()
功能说明:获取DgnRotationalSweep旋转轴
代码示例:
public void GetAxisTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建圆作为旋转体的端面,指定旋转体的旋转轴
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Inner);
//新建dgn旋转体信息
Bentley.GeometryNET.DgnRotationalSweep dgnRotationalSweepDetail = new Bentley.GeometryNET.DgnRotationalSweep(curvePrimitives, DPoint3d.Zero, DVector3d.UnitZ, UorPerMas, true);
//获取旋转轴
DVector3d res = dgnRotationalSweepDetail.GetAxis();
//转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element.AddToModel();
}
GetBaseGeometry()
功能说明:获取DgnRotationalSweep基本的几何
代码示例:
public void GetBaseGeometryTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建圆作为旋转体的端面,指定旋转体的旋转轴
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Inner);
//新建dgn旋转体信息
Bentley.GeometryNET.DgnRotationalSweep dgnRotationalSweepDetail = new Bentley.GeometryNET.DgnRotationalSweep(curvePrimitives, DPoint3d.Zero, DVector3d.UnitZ, UorPerMas, true);
// 获取基本几何信息
ISweepable sweepable = dgnRotationalSweepDetail.GetBaseGeometry();
//转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element.AddToModel();
}
GetCapped ()
功能说明:获取DgnRotationalSweep是否闭合
代码示例:
public void GetCappedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建圆作为旋转体的端面,指定旋转体的旋转轴
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Inner);
//新建dgn旋转体信息
Bentley.GeometryNET.DgnRotationalSweep dgnRotationalSweepDetail = new Bentley.GeometryNET.DgnRotationalSweep(curvePrimitives, DPoint3d.Zero, DVector3d.UnitZ, UorPerMas, true);
// 获取是否闭合
bool res = dgnRotationalSweepDetail.GetCapped();
//转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element.AddToModel();
}
GetCenter()
功能说明:获取DgnRotationalSweep的中点
代码示例:
public void GetCenterTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建圆作为旋转体的端面,指定旋转体的旋转轴
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Inner);
//新建dgn旋转体信息
Bentley.GeometryNET.DgnRotationalSweep dgnRotationalSweepDetail = new Bentley.GeometryNET.DgnRotationalSweep(curvePrimitives, DPoint3d.Zero, DVector3d.UnitZ, UorPerMas, true);
// 获取中点
DPoint3d res = dgnRotationalSweepDetail.GetCenter();
//转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element.AddToModel();
}
GetSweepAngle()
功能说明:获取旋转角度
代码示例:
public void GetSweepAngleTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建圆作为旋转体的端面,指定旋转体的旋转轴
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Inner);
//新建dgn旋转体信息
Bentley.GeometryNET.DgnRotationalSweep dgnRotationalSweepDetail = new Bentley.GeometryNET.DgnRotationalSweep(curvePrimitives, DPoint3d.Zero, DVector3d.UnitZ, UorPerMas, true);
// 获取旋转角度
Angle res = dgnRotationalSweepDetail.GetSweepAngle();
//转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element.AddToModel();
}
SetAxis()
功能说明:设置旋转轴
代码示例:
public void SetAxisTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建圆作为旋转体的端面,指定旋转体的旋转轴
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Inner);
//新建dgn旋转体信息
Bentley.GeometryNET.DgnRotationalSweep dgnRotationalSweepDetail = new Bentley.GeometryNET.DgnRotationalSweep(curvePrimitives, DPoint3d.Zero, DVector3d.UnitZ, UorPerMas, true);
//转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element.AddToModel();
//设置新的旋转轴
dgnRotationalSweepDetail.SetAxis(DVector3d.UnitX);
//转化为element,并持久化到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element1.AddToModel();
}
SetBaseGeometry()
功能说明:
代码示例:
SetCapped()
功能说明:设置DgnRotationalSweep是否闭合
代码示例:
public void SetCappedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建圆作为旋转体的端面,指定旋转体的旋转轴
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Inner);
//新建dgn旋转体信息
Bentley.GeometryNET.DgnRotationalSweep dgnRotationalSweepDetail = new Bentley.GeometryNET.DgnRotationalSweep(curvePrimitives, DPoint3d.Zero, DVector3d.UnitZ, UorPerMas, true);
//转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element.AddToModel();
//设置新的闭合状态
dgnRotationalSweepDetail.SetCapped(false);
//转化为element,并持久化到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element1.AddToModel();
}
SetCenter()
功能说明:为DgnRotationalSweep设置新的中心点
代码示例:
public void SetCenterTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建圆作为旋转体的端面,指定旋转体的旋转轴
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Inner);
//新建dgn旋转体信息
Bentley.GeometryNET.DgnRotationalSweep dgnRotationalSweepDetail = new Bentley.GeometryNET.DgnRotationalSweep(curvePrimitives, DPoint3d.Zero, DVector3d.UnitZ, UorPerMas, true);
//转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element.AddToModel();
//设置新的中心点
dgnRotationalSweepDetail.SetCenter(new DPoint3d(UorPerMas,UorPerMas,UorPerMas));
//转化为element,并持久化到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element1.AddToModel();
}
SetSweepAngle()
功能说明:为DgnRotationalSweep设置转转角度
代码示例:
public void SetSweepAngleTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建圆作为旋转体的端面,指定旋转体的旋转轴
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Inner);
//新建dgn旋转体信息
Bentley.GeometryNET.DgnRotationalSweep dgnRotationalSweepDetail = new Bentley.GeometryNET.DgnRotationalSweep(curvePrimitives, DPoint3d.Zero, DVector3d.UnitZ, UorPerMas, true);
//转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element.AddToModel();
//设置新的旋转角度
dgnRotationalSweepDetail.SetSweepAngle(0.8*Angle.PI);
//转化为element,并持久化到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, dgnRotationalSweepDetail, null);
element1.AddToModel();
}
ValidateConstruction()
功能说明:
代码示例:
属性:
AsIGeometry { get; }
功能说明:
代码示例:
1.4.2.4.6 DgnRuledSweep
说明:强类型、兼容CommonGeoemtry的DgnRuledSweep。
构造函数:
DgnRuledSweep(IEnumerable
功能说明:构造函数,新建一个DgnRuledSweep对象
代码示例:
public void DgnRuledSweepTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<CurveVector> curvePrimitives = new List<CurveVector>();
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
dPoint3Ds.Add(new DPoint3d(100000, 40000, 0));
//创建CurveVector列表
DEllipse3d dEllipse3D0 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[0], UorPerMas, DVector3d.UnitX);
DEllipse3d dEllipse3D1 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[1], 0.5*UorPerMas, DVector3d.UnitY);
DEllipse3d dEllipse3D2 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[2], 0.8*UorPerMas, DVector3d.UnitZ);
DEllipse3d dEllipse3D3 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[3], 1.5*UorPerMas, DVector3d.UnitX);
DEllipse3d dEllipse3D4 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[4], 0.9*UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitive = CurveVector.CreateDisk(dEllipse3D0, CurveVector.BoundaryType.Open );
CurveVector curvePrimitive0 = CurveVector.CreateDisk(dEllipse3D1, CurveVector.BoundaryType.Open );
CurveVector curvePrimitive1 = CurveVector.CreateDisk(dEllipse3D2, CurveVector.BoundaryType.Open );
CurveVector curvePrimitive2 = CurveVector.CreateDisk(dEllipse3D3, CurveVector.BoundaryType.Open );
CurveVector curvePrimitive3 = CurveVector.CreateDisk(dEllipse3D4, CurveVector.BoundaryType.Open);
curvePrimitives.Add(curvePrimitive);
curvePrimitives.Add(curvePrimitive0);
curvePrimitives.Add(curvePrimitive1);
curvePrimitives.Add(curvePrimitive2);
curvePrimitives.Add(curvePrimitive3);
//创建规则拉伸体 DgnRuledSweep
Bentley.GeometryNET.DgnRuledSweep dgnRuledSweepDetail = new Bentley.GeometryNET.DgnRuledSweep(curvePrimitives, true);
//转化为element 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRuledSweepDetail, null);
element.AddToModel();
}
DgnRuledSweep(CurveVector, CurveVector, Boolean)
功能说明:构造函数,新建一个DgnRuledSweep对象
代码示例:
public void DgnRuledSweepTest2()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<CurveVector> curvePrimitives = new List<CurveVector>();
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
dPoint3Ds.Add(new DPoint3d(100000, 40000, 0));
//创建CurveVector列表
DEllipse3d dEllipse3D0 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[0], UorPerMas, DVector3d.UnitX);
DEllipse3d dEllipse3D1 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[1], 0.5 * UorPerMas, DVector3d.UnitY);
DEllipse3d dEllipse3D2 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[2], 0.8 * UorPerMas, DVector3d.UnitZ);
DEllipse3d dEllipse3D3 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[3], 1.5 * UorPerMas, DVector3d.UnitX);
DEllipse3d dEllipse3D4 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[4], 0.9 * UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitive = CurveVector.CreateDisk(dEllipse3D0, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive0 = CurveVector.CreateDisk(dEllipse3D1, CurveVector.BoundaryType.Open);
curvePrimitives.Add(curvePrimitive);
curvePrimitives.Add(curvePrimitive0);
//创建规则拉伸体 DgnRuledSweep
Bentley.GeometryNET.DgnRuledSweep dgnRuledSweepDetail = new Bentley.GeometryNET.DgnRuledSweep(curvePrimitives[0], curvePrimitives[1], true);
//转化为element 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRuledSweepDetail, null);
element.AddToModel();
}
方法:
AddContour()
功能说明:
代码示例:
Contours()
功能说明:
代码示例:
DispatchToDDHandler()
功能说明:
代码示例:
GetCapped()
功能说明:获取DgnRuledSweep的闭合信息
代码示例:
public void GetCappedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<CurveVector> curvePrimitives = new List<CurveVector>();
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
dPoint3Ds.Add(new DPoint3d(100000, 40000, 0));
//创建CurveVector列表
DEllipse3d dEllipse3D0 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[0], UorPerMas, DVector3d.UnitX);
DEllipse3d dEllipse3D1 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[1], 0.5 * UorPerMas, DVector3d.UnitY);
DEllipse3d dEllipse3D2 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[2], 0.8 * UorPerMas, DVector3d.UnitZ);
DEllipse3d dEllipse3D3 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[3], 1.5 * UorPerMas, DVector3d.UnitX);
DEllipse3d dEllipse3D4 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[4], 0.9 * UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitive = CurveVector.CreateDisk(dEllipse3D0, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive0 = CurveVector.CreateDisk(dEllipse3D1, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive1 = CurveVector.CreateDisk(dEllipse3D2, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive2 = CurveVector.CreateDisk(dEllipse3D3, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive3 = CurveVector.CreateDisk(dEllipse3D4, CurveVector.BoundaryType.Open);
curvePrimitives.Add(curvePrimitive);
curvePrimitives.Add(curvePrimitive0);
curvePrimitives.Add(curvePrimitive1);
curvePrimitives.Add(curvePrimitive2);
curvePrimitives.Add(curvePrimitive3);
//创建规则拉伸体 DgnRuledSweep
Bentley.GeometryNET.DgnRuledSweep dgnRuledSweepDetail = new Bentley.GeometryNET.DgnRuledSweep(curvePrimitives, true);
//转化为element 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRuledSweepDetail, null);
element.AddToModel();
// 获取是否闭合的信息,并打印出来
bool res = dgnRuledSweepDetail.GetCapped();
System.Windows.Forms.MessageBox.Show("is this DgnRuledSweep capped ? " + res.ToString());
}
GetContourCount()
功能说明:获取DgnRuledSweep拉伸端面的数目
代码示例:
public void GetContourCountTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<CurveVector> curvePrimitives = new List<CurveVector>();
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
dPoint3Ds.Add(new DPoint3d(100000, 40000, 0));
//创建CurveVector列表
DEllipse3d dEllipse3D0 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[0], UorPerMas, DVector3d.UnitX);
DEllipse3d dEllipse3D1 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[1], 0.5 * UorPerMas, DVector3d.UnitY);
DEllipse3d dEllipse3D2 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[2], 0.8 * UorPerMas, DVector3d.UnitZ);
DEllipse3d dEllipse3D3 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[3], 1.5 * UorPerMas, DVector3d.UnitX);
DEllipse3d dEllipse3D4 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[4], 0.9 * UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitive = CurveVector.CreateDisk(dEllipse3D0, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive0 = CurveVector.CreateDisk(dEllipse3D1, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive1 = CurveVector.CreateDisk(dEllipse3D2, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive2 = CurveVector.CreateDisk(dEllipse3D3, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive3 = CurveVector.CreateDisk(dEllipse3D4, CurveVector.BoundaryType.Open);
curvePrimitives.Add(curvePrimitive);
curvePrimitives.Add(curvePrimitive0);
curvePrimitives.Add(curvePrimitive1);
curvePrimitives.Add(curvePrimitive2);
curvePrimitives.Add(curvePrimitive3);
//创建规则拉伸体 DgnRuledSweep
Bentley.GeometryNET.DgnRuledSweep dgnRuledSweepDetail = new Bentley.GeometryNET.DgnRuledSweep(curvePrimitives, true);
//转化为element 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRuledSweepDetail, null);
element.AddToModel();
// 获取是拉伸端面的信息,并打印出来
int res = dgnRuledSweepDetail.GetContourCount();
System.Windows.Forms.MessageBox.Show("this DgnRuledSweep's profiles number is " + res.ToString());
}
SetCapped()
功能说明:设置DgnRuledSweep是否闭合
代码示例:
public void SetCappedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
List<CurveVector> curvePrimitives = new List<CurveVector>();
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
dPoint3Ds.Add(new DPoint3d(100000, 40000, 0));
//创建CurveVector列表
DEllipse3d dEllipse3D0 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[0], UorPerMas, DVector3d.UnitX);
DEllipse3d dEllipse3D1 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[1], 0.5 * UorPerMas, DVector3d.UnitY);
DEllipse3d dEllipse3D2 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[2], 0.8 * UorPerMas, DVector3d.UnitZ);
DEllipse3d dEllipse3D3 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[3], 1.5 * UorPerMas, DVector3d.UnitX);
DEllipse3d dEllipse3D4 = DEllipse3d.FromCenterRadiusNormal(dPoint3Ds[4], 0.9 * UorPerMas, DVector3d.UnitY);
CurveVector curvePrimitive = CurveVector.CreateDisk(dEllipse3D0, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive0 = CurveVector.CreateDisk(dEllipse3D1, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive1 = CurveVector.CreateDisk(dEllipse3D2, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive2 = CurveVector.CreateDisk(dEllipse3D3, CurveVector.BoundaryType.Open);
CurveVector curvePrimitive3 = CurveVector.CreateDisk(dEllipse3D4, CurveVector.BoundaryType.Open);
curvePrimitives.Add(curvePrimitive);
curvePrimitives.Add(curvePrimitive0);
curvePrimitives.Add(curvePrimitive1);
curvePrimitives.Add(curvePrimitive2);
curvePrimitives.Add(curvePrimitive3);
//创建规则拉伸体 DgnRuledSweep
Bentley.GeometryNET.DgnRuledSweep dgnRuledSweepDetail = new Bentley.GeometryNET.DgnRuledSweep(curvePrimitives, true);
//转化为element 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnRuledSweepDetail, null);
element.AddToModel();
// 设置闭合为否
bool res = dgnRuledSweepDetail.SetCapped(false);
//转化为element 添加到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, dgnRuledSweepDetail, null);
element1.AddToModel();
}
ValidateConstruction()
功能说明:
代码示例:
属性:
AsIGeometry { get; }
功能说明:
代码示例:
1.4.2.4.7 DgnSphere
说明:强类型、兼容CommonGeoemtry的DgnSphere。
构造函数:
DgnSphere(DPoint3d, Double)
功能说明:DgnSphere的构造函数
代码示例:
public void DgnSphereTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个dgn圆柱体
Bentley.GeometryNET.DgnSphere dgnSphereDetail = new Bentley.GeometryNET.DgnSphere(DPoint3d.Zero, UorPerMas);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnSphereDetail, null);
element.AddToModel();
}
DgnSphere(DPoint3d, DMatrix3d, Double)
功能说明:DgnSphere的构造函数
代码示例:
public void DgnSphereTest2()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个dgn圆柱体
Bentley.GeometryNET.DgnSphere dgnSphereDetail = new Bentley.GeometryNET.DgnSphere(DPoint3d.Zero, DMatrix3d.Identity, UorPerMas);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnSphereDetail, null);
element.AddToModel();
}
DgnSphere(DPoint3d, DVector3d, DVector3d, Double, Double, Angle, Angle, Boolean)
功能说明:DgnSphere的构造函数
代码示例:
public void DgnSphereTest3()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个dgn圆柱体
Bentley.GeometryNET.DgnSphere dgnSphereDetail = new Bentley.GeometryNET.DgnSphere(DPoint3d.Zero, DVector3d.UnitX,DVector3d.UnitZ,UorPerMas,2*UorPerMas,Angle.Zero,Angle.TWOPI,true);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnSphereDetail, null);
element.AddToModel();
}
方法:
DispatchToDDHandler ()
功能说明:
代码示例:
GetDgnSphere ()
功能说明:获取DgnSphere的信息
代码示例:
public void GetDgnSphereTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个dgn圆柱体
Bentley.GeometryNET.DgnSphere dgnSphereDetail = new Bentley.GeometryNET.DgnSphere(DPoint3d.Zero, UorPerMas);
// 获取DgnSphere 的信息
dgnSphereDetail.GetDgnSphere(out DPoint3d center, out DVector3d vectorX, out DVector3d vectorZ, out double radiusXY, out double radiusZ, out Angle startLatitude, out Angle latitudeSweep, out bool capped);
//将SolidPrimitive转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnSphereDetail, null);
element.AddToModel();
}
属性:
AsIGeometry { get; }
功能说明:
代码示例:
1.4.2.4.8 DgnTorusPipe
说明:强类型、兼容CommonGeoemtry的DgnTorusPipe。
构造函数:
DgnTorusPipe()
功能说明:构造函数,创建一个DgnTorusPipe对象
代码示例:
public void DgnTorusPipeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建dgn环管
Bentley.GeometryNET.DgnTorusPipe dgnTorusPipeDetail = new Bentley.GeometryNET.DgnTorusPipe(DPoint3d.Zero, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, 0.5 * UorPerMas, Angle.NEGATIVE_PI, true);
//转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnTorusPipeDetail, null);
element.AddToModel();
}
方法:
DispatchToDDHandler ()
功能说明:
代码示例:
GetDgnTorusPipe ()
功能说明:获取DgnTorusPipe的信息
代码示例:
public void GetDgnTorusPipeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建dgn环管
Bentley.GeometryNET.DgnTorusPipe dgnTorusPipeDetail = new Bentley.GeometryNET.DgnTorusPipe(DPoint3d.Zero, DVector3d.UnitX, DVector3d.UnitY, UorPerMas, 0.5 * UorPerMas, Angle.PI, true);
// 获取DgnTorusPipe的信息
dgnTorusPipeDetail.GetDgnTorusPipe(out DPoint3d center, out DVector3d vectorX, out DVector3d vectorY, out double majorRadius, out double minorRadius, out Angle sweepAngle, out bool capped);
//转化为element,并持久化到model中
Element element = DraftingElementSchema.ToElement(dgnModel, dgnTorusPipeDetail, null);
element.AddToModel();
}
属性:
AsIGeometry { get; }
功能说明:
代码示例:
1.4.2.4.9 Sphere
说明:强类型、兼容CommonGeoemtry的Sphere。
构造函数:
Sphere()
功能说明:
代码示例:
方法:
DispatchToDDHandler ()
功能说明:
代码示例:
GetSphere ()
功能说明:
代码示例:
属性:
AsIGeometry { get; }
功能说明:
代码示例:
1.4.2.4.10 TorusPipe
说明:强类型、兼容CommonGeoemtry的TorusPipe。
构造函数:
TorusPipe()
功能说明:
代码示例:
方法:
DispatchToDDHandler ()
功能说明:
代码示例:
GetTorusPipe ()
功能说明:
代码示例:
属性:
AsIGeometry { get; }
功能说明:
代码示例:
1.5 AnySurface
说明:
方法:
属性:
1.5.1 AnyParametricSurface
说明:
方法:
属性:
1.5.2 CurveBoundedRegion
说明:
方法:
属性:
1.5.2.1 CurvePrimitiveCollection
说明:
方法:
属性:
1.5.2.1.1 UnionRegion
说明:
方法:
属性:
1.5.2.2 CurvePrimitiveCollection
说明:
方法:
属性:
1.5.2.2.1 CurveVector
说明:CurveVector是曲线基元的集合,该集合有一个特定的边界类型,是它作为开链、单个循环(内部或外部),或者多个循环的父循环。可以用来表示路径、回路、多回路区域和集合。
构造器:
CurveVector()
功能说明:构造函数,创建一个空的CurveVector对象
代码示例:
public void CurveVectorTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//构造函数新建一个CurveVector对象
Bentley.GeometryNET.CurveVector curvePrimitives11 = new Bentley.GeometryNET.CurveVector(Bentley.GeometryNET.CurveVector.BoundaryType.Outer);
//新建一个 CurveVector
DVector3d dVector3D = new DVector3d(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 3 * UorPerMas, dVector3D);
Bentley.GeometryNET.CurveVector curvePrimitives = Bentley.GeometryNET.CurveVector.CreateDisk(dEllipse3D, Bentley.GeometryNET.CurveVector.BoundaryType.Outer);
curvePrimitives11 = curvePrimitives;
//将平面上方的曲线转化为element,并添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives11, null);
element.AddToModel();
}
方法:
AppendSplitCurvesByPlane ()
功能说明:通过平面分裂曲线
代码示例:
public void AppendSplitCurvesByPlaneTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
DVector3d dVector3D = new DVector3d(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 3*UorPerMas, dVector3D);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Outer);
// 准备切割线的平面
DPlane3d dPlane3D = new DPlane3d(DPoint3d.Zero, DVector3d.UnitX);
// 准备空的接收函数执行结果的 CurveVector
CurveVector belowCollector = CurveVector.Create(CurveVector.BoundaryType.Outer);
CurveVector aboveCollector = CurveVector.Create(CurveVector.BoundaryType.Outer);
CurveVector onCollector = CurveVector.Create(CurveVector.BoundaryType.Outer);
//使用方法,得到平面切割后的曲线
curvePrimitives.AppendSplitCurvesByPlane(dPlane3D, belowCollector, aboveCollector, onCollector);
//将平面上方的曲线转化为element,并添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, aboveCollector, null);
element.AddToModel();
}
AppendSplitCurvesByRegion ()
功能说明:使用region切割曲线,返回region上、内部、外部的曲线
代码示例:
public void AppendSplitCurvesByRegionTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
//DVector3d dVector3D = new DVector3d(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 2*UorPerMas, DVector3d.UnitZ);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Outer);
// 新建一个用于切割的CurveVector
DEllipse3d dEllipse3D1 = DEllipse3d.FromCenterRadiusNormal(new DPoint3d(UorPerMas,0,0), 2* UorPerMas, DVector3d.UnitZ);
CurveVector region = CurveVector.CreateDisk(dEllipse3D1, CurveVector.BoundaryType.Outer);
// 准备空的接收函数执行结果的 CurveVector
CurveVector insideCollector = CurveVector.Create(CurveVector.BoundaryType.Outer);
CurveVector outsideCollector = CurveVector.Create(CurveVector.BoundaryType.Outer);
CurveVector onCollector = CurveVector.Create(CurveVector.BoundaryType.Outer);
//使用方法,获取区域内、外,和区域上的CurveVector
curvePrimitives.AppendSplitCurvesByRegion(region, insideCollector, outsideCollector, onCollector);
//将区域内的曲线转化为element,并添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, insideCollector, null);
element.AddToModel();
}
AreaDifference ()
功能说明:求两个curveVector相减的区域
代码示例:
public void AreaDifferenceTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建两个 CurveVector
//DVector3d dVector3D = new DVector3d(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 2 * UorPerMas, DVector3d.UnitZ);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Outer);
DEllipse3d dEllipse3D1 = DEllipse3d.FromCenterRadiusNormal(new DPoint3d(UorPerMas, 0, 0), 2 * UorPerMas, DVector3d.UnitZ);
CurveVector region = CurveVector.CreateDisk(dEllipse3D1, CurveVector.BoundaryType.Outer);
// 求两个CurveVector的不同部分,将结果转化为element, 添加到model中
CurveVector result = CurveVector.AreaDifference(curvePrimitives, region);
Element element = DraftingElementSchema.ToElement(dgnModel, result, null);
element.AddToModel();
}
AreaIntersection ()
功能说明:求两个CurveVector的相交区域
代码示例:
public void AreaIntersectionTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建两个 CurveVector
//DVector3d dVector3D = new DVector3d(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 2 * UorPerMas, DVector3d.UnitZ);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Outer);
DEllipse3d dEllipse3D1 = DEllipse3d.FromCenterRadiusNormal(new DPoint3d(UorPerMas, 0, 0), 2 * UorPerMas, DVector3d.UnitZ);
CurveVector region = CurveVector.CreateDisk(dEllipse3D1, CurveVector.BoundaryType.Outer);
// 求两个CurveVector的相交部分,将结果转化为element, 添加到model中
CurveVector result = CurveVector.AreaIntersection(curvePrimitives, region);
Element element = DraftingElementSchema.ToElement(dgnModel, result, null);
element.AddToModel();
}
AreaOffset ()
功能说明:设置曲线区域偏移
代码示例:
public void AreaOffsetTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 0));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//偏移曲线区域
CurveVector result = curvePrimitives.AreaOffset(3*UorPerMas, 0, 0);
//将原曲线和偏移后的曲线转为element, 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, result, null);
element.AddToModel();
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element1.AddToModel();
}
AreaParity ()
功能说明:返回去除两个曲线公共区域之后部分
代码示例:
public void AreaParityTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建两个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 0));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 3 * UorPerMas, DVector3d.UnitZ);
CurveVector curvePrimitives1 = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Outer);
//返回去除两个曲线公共区域之后部分
CurveVector curvePrimitives11 = CurveVector.AreaParity(curvePrimitives, curvePrimitives1);
//以上三个曲线转为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives1, null);
element1.AddToModel();
Element element11 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives11, null);
element11.AddToModel();
}
AreaUnion ()
功能说明:返回两个曲线合并后的区域
代码示例:
public void AreaUnionTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建两个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 0));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 3 * UorPerMas, DVector3d.UnitZ);
CurveVector curvePrimitives1 = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Outer);
//返回两个曲线合并后的区域
CurveVector curvePrimitives11 = CurveVector.AreaUnion(curvePrimitives, curvePrimitives1);
//以上三个曲线转为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives1, null);
element1.AddToModel();
Element element11 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives11, null);
element11.AddToModel();
}
CentroidAreaXY ()
功能说明:返回在xy平面上看到的曲线矢量的形心和面积。如果曲率面不是区域类型之一(联合区域、宇称区域或闭环),则返回false。
代码示例:
public void CentroidAreaXYTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 倾斜的圆
DVector3d dVector3D = new DVector3d(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 3 * UorPerMas, dVector3D);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Outer);
//返回在xy平面上看到的曲线矢量的形心和面积
bool res = curvePrimitives.CentroidAreaXY(out DPoint3d centerPt, out double area);
bool ress = curvePrimitives.CentroidNormalArea(out DPoint3d dPoint3Dss, out DVector3d dVector3D1, out double areass);
System.Windows.Forms.MessageBox.Show("the AreaXY is "+ area.ToString()+ "\n\r the initial area is " + areass.ToString());
}
CentroidNormalArea ()
功能说明:返回曲线向量的形心、法向量和面积。如果曲率面不是区域类型之一(联合区域、宇称区域或闭环),则返回false
代码示例:
public void CentroidNormalAreaTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 倾斜的圆
DVector3d dVector3D = new DVector3d(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 3 * UorPerMas, dVector3D);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Outer);
//返回曲线向量的形心、法向量和面积
bool ress = curvePrimitives.CentroidNormalArea(out DPoint3d dPoint3Dss, out DVector3d dVector3D1, out double areass);
System.Windows.Forms.MessageBox.Show(" the initial area is " + areass.ToString());
}
Clone ()
功能说明:深度拷贝
代码示例:
public void CloneTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 倾斜的圆
DVector3d dVector3D = new DVector3d(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 3 * UorPerMas, dVector3D);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Outer);
//对上一步骤创建的曲线深度拷贝
CurveVector curvePrimitives1 = curvePrimitives.Clone();
//以上两个曲线转为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives1, null);
element1.AddToModel();
}
CloneAsBsplines ()
功能说明:返回curvePrimitives的深度复制,并将其中的curvePrimitives替换为B样条曲线,并且其上部树结构被保留
代码示例:
public void CloneAsBsplinesTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 倾斜的圆
DVector3d dVector3D = new DVector3d(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 3 * UorPerMas, dVector3D);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Outer);
//返回curvePrimitives的深度复制,并将其中的curvePrimitives替换为B样条曲线
CurveVector curvePrimitives1 = curvePrimitives.CloneAsBsplines();
//以上两个曲线转为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives1, null);
element1.AddToModel();
}
CloneBetweenCyclicIndexedFractions ()
功能说明:深度拷贝index0的fractionA到index1的fractionB之间的曲线,支持循环拷贝
代码示例:
public void CloneBetweenCyclicIndexedFractionsTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 0));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
// 深度拷贝index0的fractionA到index1的fractionB之间的曲线
CurveVector curvePrimitives1 = curvePrimitives.CloneBetweenCyclicIndexedFractions(2, 0.2, 0, 0.6);
//以上两个曲线转为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives1, null);
element1.AddToModel();
}
CloneBetweenDirectedFractions ()
功能说明:深度拷贝index0的fractionA到index1的fractionB之间的曲线,不支持循环拷贝,仅能按照索引顺序
代码示例:
public void CloneBetweenDirectedFractionsTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 0));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
// 深度拷贝index0的fractionA到index1的fractionB之间的曲线
CurveVector curvePrimitives1 = curvePrimitives.CloneBetweenDirectedFractions(0, 0.2, 2, 0.6,false);
//以上两个曲线转为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives1, null);
element1.AddToModel();
}
CloneDereferenced ()
功能说明:
代码示例:
CloneOffsetCurvesXY ()
功能说明:返回曲线带符号(正负号表示放大缩小)的距离偏移后的(深度)克隆。这是一种曲线运算,可能会得到自相交的偏移曲线。
代码示例:
public void CloneOffsetCurvesXYTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 0));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//以上曲线转为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
//偏移曲线(该例子得到了自相交的曲线)
CurveVector curvePrimitives1 = curvePrimitives.CloneOffsetCurvesXY(4 * UorPerMas, 0, 0);
//以上曲线转为element,添加到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives1, null);
element1.AddToModel();
}
CloneWithFillets ()
功能说明:返回曲线倒角后的深度克隆
代码示例:
public void CloneWithFilletsTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 0));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//以上曲线转为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 深度克隆并倒角
CurveVector curvePrimitives1 = curvePrimitives.CloneWithFillets(0.1 * UorPerMas);
//以上曲线转为element,添加到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives1, null);
element1.AddToModel();
}
CloneWithSplits ()
功能说明:返回曲线被分割后的深度克隆
代码示例:
public void CloneWithSplitsTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 0));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
// 新建分割的曲线
List<DPoint3d> dPoint3Dss = new List<DPoint3d>();
dPoint3Dss.Add(new DPoint3d(-2*UorPerMas, -0, 0));
dPoint3Dss.Add(new DPoint3d(2*UorPerMas, 0, 0));
CurveVector curvePrimitives0 = CurveVector.CreateLinear(dPoint3Dss, CurveVector.BoundaryType.Inner, false);
//源曲线转化为element 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
//对曲线进行分割
CurveVector curvePrimitives1 = curvePrimitives.CloneWithSplits(curvePrimitives0);
//以上曲线转为element,添加到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives1, null);
element1.AddToModel();
}
ClosestPointBounded ()
功能说明:获取曲线上离目标点最近的点
代码示例:
public void ClosestPointBoundedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 0));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//转化为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取曲线上离目标点最近的点
CurveLocationDetail res = curvePrimitives.ClosestPointBounded(new DPoint3d(-1.1 * UorPerMas, -UorPerMas, 0));
//将目标点和曲线上的最近点连成直线,添加到model中
DSegment3d dSegment3D = new DSegment3d(new DPoint3d(-1.1 * UorPerMas, -UorPerMas, 0), res.Point);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
ClosestPointBoundedXY(DPoint3d)
功能说明:仅使用XY坐标获取离曲线上最近的点
代码示例:
public void ClosestPointBoundedXYTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0.3 * UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0.8 * UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 1.3 * UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//转化为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取曲线上离目标点最近的点
CurveLocationDetail res = curvePrimitives.ClosestPointBoundedXY(new DPoint3d(-1.1 * UorPerMas, -UorPerMas, 0));
//将目标点和曲线上的最近点连成直线,添加到model中
DSegment3d dSegment3D = new DSegment3d(new DPoint3d(-1.1 * UorPerMas, -UorPerMas, 0), res.Point);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
ClosestPointBoundedXY(DPoint3d, DMatrix4d)
功能说明:仅使用XY坐标获取离曲线上最近的点
代码示例:
public void ClosestPointBoundedXYTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0.3*UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0.8*UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 1.3*UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//转化为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取曲线上离目标点最近的点
CurveLocationDetail res = curvePrimitives.ClosestPointBoundedXY(new DPoint3d(-1.1 * UorPerMas, -UorPerMas, 0),DMatrix4d.Identity);
//将目标点和曲线上的最近点连成直线,添加到model中
DSegment3d dSegment3D = new DSegment3d(new DPoint3d(-1.1 * UorPerMas, -UorPerMas, 0), res.Point);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
ComputeSecondMomentAreaProducts ()
功能说明:返回曲线的面积、质心、方向和主力矩,计算时将其视为一个薄平面。
代码示例:
public void ComputeSecondMomentAreaProductsTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0.3 * UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0.8 * UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 1.3 * UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//转化为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取返回曲线的面积、质心、方向和主力矩,存在矩阵中
bool result = curvePrimitives.ComputeSecondMomentAreaProducts(out DMatrix4d dMatrix4D);
if (result )
{
System.Windows.Forms.MessageBox.Show("get the SecondMomentAreaProducts successfully");
}
}
ComputeSecondMomentWireProducts ()
功能说明:返回面积、质心、方向和主要力矩,计算时将其视为一条线
代码示例:
public void ComputeSecondMomentWireProductsTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0.3 * UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0.8 * UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 1.3 * UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//转化为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取返回曲线的面积、质心、方向和主力矩,存在矩阵中
bool result = curvePrimitives.ComputeSecondMomentWireProducts(out DMatrix4d dMatrix4D);
if (result)
{
System.Windows.Forms.MessageBox.Show("get the SecondMomentWireProducts successfully");
}
}
ConsolidateAdjacentPrimitives ()
功能说明:合并更新相邻的部件;相邻的线和线串会变成单个线串;消除线串内部的公众点;相邻和兼容的弧会变成单弧
代码示例:
public void ConsolidateAdjacentPrimitivesTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0.3 * UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0.8 * UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//转化为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
DSegment3d dSegment3D = new DSegment3d(dPoint3Ds[2], new DPoint3d(3*UorPerMas, 6*UorPerMas, UorPerMas));
CurvePrimitive curvePrimitive = CurvePrimitive.CreateLine(dSegment3D);
curvePrimitives.Add(curvePrimitive);
//合并相邻的部件
curvePrimitives.ConsolidateAdjacentPrimitives();
//转化为element,添加到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element1.AddToModel();
}
CountPrimitivesOfType ()
功能说明:获取曲线中某种类型曲线的数量
代码示例:
public void CountPrimitivesOfTypeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0.3 * UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0.8 * UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//转化为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
//获取曲线中某种类型曲线的数量
int res = curvePrimitives.CountPrimitivesOfType(CurvePrimitive.CurvePrimitiveType.LineString);
System.Windows.Forms.MessageBox.Show("the count of LineString in this curve vector is " + res.ToString());
}
Create ()
功能说明:创建一个特定类型的空的曲线对象
代码示例:
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建一个特定类型的空的曲线对象
CurveVector curvePrimitives = CurveVector.Create(CurveVector.BoundaryType.Inner);
CreateDisk ()
功能说明:静态方法,创建圆弧
代码示例:
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
DVector3d dVector3D = new DVector3d(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 3 * UorPerMas, dVector3D);
CurveVector curvePrimitives = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Outer);
//将平面上方的曲线转化为element,并添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
CreateFromNative ()
功能说明:从指针创建曲线
代码示例:
public void CreateFromNativeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
DEllipse3d dEllipse3D = new DEllipse3d(0 * UorPerMas, 5 * UorPerMas, 0 * UorPerMas, 10 * UorPerMas, 10 * UorPerMas, 0 * UorPerMas); //创建DEllipse3d
//新建一个 CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateArc(dEllipse3D);
// 获取指针
IntPtr intPtr = CurvePrimitive.DereferenceToNative(curvePrimitive, false);
// 从指针创建曲线
CurveVector curvePrimitives = CurveVector.CreateFromNative(intPtr);
//将平面上方的曲线转化为element,并添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
}
CreateLinear ()
功能说明:创建线串曲线
代码示例:
public void CreateLinearTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建两个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 0));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//将平面上方的曲线转化为element,并添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
}
CreateStrongTypeFromNativeCurveVector ()
功能说明:使用指针创建新的曲线
代码示例:
public void CreateStrongTypeFromNativeCurveVectorTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
DEllipse3d dEllipse3D = new DEllipse3d(0 * UorPerMas, 5 * UorPerMas, 0 * UorPerMas, 10 * UorPerMas, 10 * UorPerMas, 0 * UorPerMas); //创建DEllipse3d
//新建一个 CurvePrimitive
CurvePrimitive curvePrimitive = CurvePrimitive.CreateArc(dEllipse3D);
// 获取指针
IntPtr intPtr = CurvePrimitive.DereferenceToNative(curvePrimitive, false);
// 从指针创建曲线
CurveVector curvePrimitives = CurveVector.CreateStrongTypeFromNativeCurveVector(intPtr,CreateAction.Clone);
//将平面上方的曲线转化为element,并添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
}
CreateXYHatch ()
功能说明:返回一个边界类型为None的曲线,其中包含线段的网格线。
代码示例:
public void CreateXYHatchTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
// 创建新的CurveVector,转化为element并添加到model中
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, 0));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, 0));
CurveVector curvePrimitives0 = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives0, null);
element.AddToModel();
//返回一个边界类型为None的曲线,其中包含线段的网格线,转化为element并添加到model中
CurveVector curvePrimitives = CurveVector.CreateXYHatch(curvePrimitives0, DPoint3d.Zero, UorPerMas, 0.25 * UorPerMas);
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element1.AddToModel();
}
CurveLocationDetailCompare ()
功能说明:如果位置0等于位置1,则返回0;位置0小于位置1则返回-1;位置0大于位置1则返回1。仅使用位置的索引和fraction来进行比较
代码示例:
public void CurveLocationDetailCompareTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
// 获取曲线的两个位置信息
CurveLocationDetail curveLocationDetail = curvePrimitives.ClosestPointBounded(DPoint3d.Zero);
CurveLocationDetail curveLocationDetail2 = curvePrimitives.ClosestPointBoundedXY(DPoint3d.Zero);
//比较两个位置,将结果打印出来
int rees = curvePrimitives.CurveLocationDetailCompare(curveLocationDetail, curveLocationDetail2);
System.Windows.Forms.MessageBox.Show("the compare result is " + rees.ToString());
}
CurveLocationDetailIndex ()
功能说明:获取曲线位置索引(仅对单个开放或者封闭的向量有效);如果没有找到则返回SIZE_MAX
代码示例:
public void CurveLocationDetailIndexTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
// 获取一个位置信息
CurveLocationDetail curveLocationDetail = curvePrimitives.ClosestPointBounded(DPoint3d.Zero);
// 获取索引值,显示在消息窗口中
uint res = curvePrimitives.CurveLocationDetailIndex(curveLocationDetail);
System.Windows.Forms.MessageBox.Show("the locarion index result is " + res.ToString());
}
CyclicIndex ()
功能说明:
代码示例:
DereferenceToNative ()
功能说明:获取指针值
代码示例:
public void DereferenceToNativeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//获取曲线的指针值,并显示在消息框中
IntPtr res = CurveVector.DereferenceToNative(curvePrimitives, true);
System.Windows.Forms.MessageBox.Show("the locarion index result is " + res.ToString());
}
FastMaxAbs ()
功能说明:返回任意坐标中绝对值最大的估计。这将检查所有的曲线,允许返回安全的近似值,如B样条的极点坐标,而不是精确的计算值
代码示例:
public void FastMaxAbsTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
// 获取绝对值最大的坐标,打印在消息窗口中
double res = curvePrimitives.FastMaxAbs();
System.Windows.Forms.MessageBox.Show("the FastMaxAbs result is " + res.ToString());
}
FixupXYOuterInner ()
功能说明:
代码示例:
GetBoundaryType ()
功能说明:获取曲线的边界类型
代码示例:
public void GetBoundaryTypeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//获取边界类型,并打印在消息框中
var res = curvePrimitives.GetBoundaryType();
System.Windows.Forms.MessageBox.Show("the BoundaryType is " + res.ToString());
}
GetPrimitive ()
功能说明:获取某个索引处的曲线
代码示例:
public void GetPrimitiveTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//转为element,添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
//获取索引为1处的曲线,转为element,添加到model中
var res = curvePrimitives.GetPrimitive(1);
Element element1 = DraftingElementSchema.ToElement(dgnModel, res, null);
element1.AddToModel();
}
GetRange ()
功能说明:获取元素的范围
代码示例:
public void GetRangeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//获取元素的范围
bool res = curvePrimitives.GetRange(out DRange3d dRange3D);
//将range的顶底点做成直线,添加到model中
DSegment3d dSegment3D = new DSegment3d(dRange3D.Low, dRange3D.High);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
GetStartEnd(DPoint3d, DPoint3d)
功能说明:获取曲线的起始点
代码示例:
public void GetStartEndTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
var res = curvePrimitives.GetStartEnd(out DPoint3d dPoint3D, out DPoint3d dPoint3DEnd);
//将曲线的起终点做成直线,添加到model中
DSegment3d dSegment3D = new DSegment3d(dPoint3D, dPoint3DEnd);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
GetStartEnd(DPoint3d, DPoint3d, DVector3d, DVector3d)
功能说明:获取曲线的起始点
代码示例:
public void GetStartEndTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
var res = curvePrimitives.GetStartEnd(out DPoint3d dPoint3D, out DPoint3d dPoint3DEnd,out DVector3d dVector3DStart,out DVector3d dVector3DEnd);
//将曲线的起终点做成直线,添加到model中
DSegment3d dSegment3D = new DSegment3d(dPoint3D, dPoint3DEnd);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
GetStartPoint ()
功能说明:获取曲线的起点
代码示例:
public void GetStartPointTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
var res = curvePrimitives.GetStartPoint(out DPoint3d dPoint3D);
//将曲线的起点和原点做成直线,添加到model中
DSegment3d dSegment3D = new DSegment3d(dPoint3D, DPoint3d.Zero);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
}
IsPlanar ()
功能说明:获取曲线的变换矩阵和范围
代码示例:
public void IsPlanarTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
var res = curvePrimitives.IsPlanar(out DTransform3d localToWorld, out DTransform3d worldToLocal, out DRange3d range);
//将曲线的起点和原点做成直线,添加到model中
DSegment3d dSegment3D = new DSegment3d(range.Low, range.High);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
IsSameStructure ()
功能说明:判断两个曲线是否有相同结构
代码示例:
public void IsSameStructureTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//新建一个 CurveVector
DVector3d dVector3D = new DVector3d(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
DEllipse3d dEllipse3D = DEllipse3d.FromCenterRadiusNormal(DPoint3d.Zero, 3 * UorPerMas, dVector3D);
CurveVector curvePrimitives1 = CurveVector.CreateDisk(dEllipse3D, CurveVector.BoundaryType.Outer);
//判断两条曲线是否有相同结构,结果打印出来
var res = curvePrimitives1.IsSameStructure(curvePrimitives);
System.Windows.Forms.MessageBox.Show("these curve is same structure or not " + res.ToString());
}
IsSameStructureAndGeometry ()
功能说明:判断两条曲线是否有相同的几何和结构
代码示例:
public void IsSameStructureAndGeometryTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//新建一个 CurveVector
CurveVector curvePrimitives1 = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Outer, false);
var res = curvePrimitives1.IsSameStructureAndGeometry(curvePrimitives,0.01*UorPerMas);
System.Windows.Forms.MessageBox.Show("these curve is same structure and Geometry or not " + res.ToString());
}
PointInOnOutXY ()
功能说明:当在XY面上观察点时,判断点是在曲线区域内、外、上。如果曲线不是一个区域,则返回INOUT_Unknown(例如 当曲线类型为 BOUNDARY_TYPE_Outer, BOUNDARY_TYPE_Inner, BOUNDARY_TYPE_ParityRegion, or BOUNDARY_TYPE_Union )
代码示例:
public void PointInOnOutXYTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
// 判断两个点的和曲线区域的关系,将结果打印出来
InOutClassification res = curvePrimitives.PointInOnOutXY(DPoint3d.Zero);
InOutClassification res1 = curvePrimitives.PointInOnOutXY(new DPoint3d(0,0,UorPerMas));
System.Windows.Forms.MessageBox.Show("the result of check point zero is " + res.ToString()+ "\n\r the result of check point (0,0,1) is " + res1.ToString() );
}
ReduceToCCWAreas ()
功能说明:清除曲线中逆时针方向的曲线,返回仅顺时针的曲线
代码示例:
public void ReduceToCCWAreasTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector,顺时针
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//新建逆时针方向的曲线
List<DPoint3d> dPoint3Dss = new List<DPoint3d>();
dPoint3Dss.Add(new DPoint3d(2*UorPerMas, -UorPerMas, -UorPerMas));
dPoint3Dss.Add(new DPoint3d(2 * UorPerMas, UorPerMas, UorPerMas));
dPoint3Dss.Add(new DPoint3d(0, -UorPerMas, UorPerMas));
dPoint3Dss.Add(new DPoint3d(0, UorPerMas, -UorPerMas));
CurvePrimitive curve = CurvePrimitive.CreateLineString(dPoint3Dss);
curvePrimitives.Add(curve);
// 返回只包含顺时针方向的曲线,转成element 添加到mnodel中
CurveVector res = CurveVector.ReduceToCCWAreas(curvePrimitives);
Element element = DraftingElementSchema.ToElement(dgnModel, res, null);
element.AddToModel();
}
ResolveTolerance ()
功能说明:根据FastMasAbs的内容返回给定公差和容许误差
代码示例:
public void ResolveToleranceTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector,顺时针
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//获取返回的误差,打印在窗口
double res = curvePrimitives.ResolveTolerance(UorPerMas * 0.00001);
System.Windows.Forms.MessageBox.Show("the returned Tolerance is " + res.ToString());
}
Stroke ()
功能说明:将曲线深度拷贝为特定样式的线条
代码示例:
public void StrokeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//转为element 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 新建一个facet option
FacetOptions facetOptions = new FacetOptions();
facetOptions.ParamDistanceScale = 0.1 * UorPerMas;
//将去爱你替换为特性样式的线条,转为element 添加到model中
CurveVector curvePrimitives1 = curvePrimitives.Stroke(facetOptions);
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives1, null);
element1.AddToModel();
}
SumOfLengths ()
功能说明:返回所有包含曲线的总长度
代码示例:
public void SumOfLengthsTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector,顺时针
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//新建逆时针方向的曲线
List<DPoint3d> dPoint3Dss = new List<DPoint3d>();
dPoint3Dss.Add(new DPoint3d(2 * UorPerMas, -UorPerMas, -UorPerMas));
dPoint3Dss.Add(new DPoint3d(2 * UorPerMas, UorPerMas, UorPerMas));
dPoint3Dss.Add(new DPoint3d(0, -UorPerMas, UorPerMas));
dPoint3Dss.Add(new DPoint3d(0, UorPerMas, -UorPerMas));
CurvePrimitive curve = CurvePrimitive.CreateLineString(dPoint3Dss);
curvePrimitives.Add(curve);
//转为element 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获得总长度 打印在消息框中
double length = curvePrimitives.SumOfLengths();
System.Windows.Forms.MessageBox.Show("the total length is " + (length/UorPerMas).ToString());
}
SwapAt ()
功能说明:交换给定下标的元素。如果任何一个索引越界,返回false
代码示例:
public void SwapAtTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//新建另一个曲线
List<DPoint3d> dPoint3Dss = new List<DPoint3d>();
dPoint3Dss.Add(new DPoint3d(2 * UorPerMas, -UorPerMas, -UorPerMas));
dPoint3Dss.Add(new DPoint3d(2 * UorPerMas, UorPerMas, UorPerMas));
dPoint3Dss.Add(new DPoint3d(0, -UorPerMas, UorPerMas));
dPoint3Dss.Add(new DPoint3d(0, UorPerMas, -UorPerMas));
CurvePrimitive curve = CurvePrimitive.CreateLineString(dPoint3Dss);
curvePrimitives.Add(curve);
//交换两个曲线位置
bool res = curvePrimitives.SwapAt(1, 0);
//将交换后的曲线转为element 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
}
Transform ()
功能说明:对曲线进行变换
代码示例:
public void TransformTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//将交换后的曲线转为element 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 对曲线进行变换
DTransform3d dTransform3D = new DTransform3d(UorPerMas,UorPerMas,UorPerMas,2*UorPerMas, 2 * UorPerMas, 2 * UorPerMas, 3 * UorPerMas, 3 * UorPerMas, 3 * UorPerMas);
bool res = curvePrimitives.Transform(dTransform3D);
//将交换后的曲线转为element 添加到model中
Element element1 = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
}
WireCentroid ()
功能说明:将曲线视为导线,返回所包含曲线的质心;返回false如果曲线为空
代码示例:
public void WireCentroidTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建一个 CurveVector
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(-UorPerMas, -UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(-UorPerMas, UorPerMas, -UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, UorPerMas, UorPerMas));
dPoint3Ds.Add(new DPoint3d(UorPerMas, -UorPerMas, -UorPerMas));
CurveVector curvePrimitives = CurveVector.CreateLinear(dPoint3Ds, CurveVector.BoundaryType.Inner, false);
//将交换后的曲线转为element 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取曲线的长度和终点
bool res = curvePrimitives.WireCentroid(out double length, out DPoint3d CenterPoint);
string XXX = (CenterPoint.X / UorPerMas).ToString();
string YYY = (CenterPoint.Y / UorPerMas).ToString();
string ZZZ = (CenterPoint.Z / UorPerMas).ToString();
// 将中点坐标打印在消息框中
System.Windows.Forms.MessageBox.Show("the CenterPoint of this curve is " + "(" + XXX + "," + YYY + "," + ZZZ + ")");
}
属性:
1.5.2.2.1.1 CircularDisk
说明:
方法:
属性:
1.5.2.2.1.2 CurveChain
说明:
方法:
属性:
1.5.2.2.1.3 DgnCurveVector
说明:
方法:
属性:
1.5.2.2.1.4 EllipticDisk
说明:
方法:
属性:
1.5.2.2.1.5 Polygon
说明:多边形几何相关的构造函数、方法和属性
构造函数:
Polygon()
功能说明:构造函数,创建一个新的Polygon对象
代码示例:
public void PolygonTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//使用构造函数创建一个新的Polygon对象
Bentley.GeometryNET.Polygon curvePrimitives = new Bentley.GeometryNET.Polygon();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
// 为空的多边形对象添加点
for (int i = 0; i < dPoint3Ds.Count; i++)
{
curvePrimitives.AddPoint(dPoint3Ds[i]);
}
// 转为element后 存储到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
}
Polygon(IEnumerable
功能说明:构造函数,创建一个新的Polygon对象
代码示例:
public void PolygonTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用构造函数创建一个新的Polygon对象
Bentley.GeometryNET.Polygon curvePrimitives = new Bentley.GeometryNET.Polygon(dPoint3Ds);
// 转为element后 存储到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
}
方法:
AddPoint()
功能说明:为polygon添加点
代码示例:
public void AddPointTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//使用构造函数创建一个新的CurveChain对象
Bentley.GeometryNET.Polygon curvePrimitives = new Bentley.GeometryNET.Polygon();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
// 为空的多边形对象添加点
for (int i = 0; i < dPoint3Ds.Count; i++)
{
curvePrimitives.AddPoint(dPoint3Ds[i]);
}
// 转为element 添加到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
}
DispatchToDDHandler()
功能说明:
代码示例:
EdgeCount()
功能说明:获取多边形边的个数
代码示例:
public void EdgeCountTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用构造函数创建一个新的Polygon对象
Bentley.GeometryNET.Polygon curvePrimitives = new Bentley.GeometryNET.Polygon(dPoint3Ds);
// 转为element后 存储到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取多边形边的个数,打印在消息框中
int res = curvePrimitives.EdgeCount();
System.Windows.Forms.MessageBox.Show("the edge count of this polygon is " + res.ToString());
}
Edges()
功能说明:获取多边形的边
代码示例:
public void EdgesTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用构造函数创建一个新的Polygon对象
Bentley.GeometryNET.Polygon curvePrimitives = new Bentley.GeometryNET.Polygon(dPoint3Ds);
// 转为element后 存储到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取多边形边的边
IEnumerable<DSegment3d> dSegment3Ds = curvePrimitives.Edges();
// 将每条边都转化为线段,存储在model中
foreach (var item in dSegment3Ds)
{
LineElement elemento = new LineElement(dgnModel, null, item);
elemento.AddToModel();
}
}
GetPointCount()
功能说明:获取多边形点的个数
代码示例:
public void GetPointCountTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用构造函数创建一个新的Polygon对象
Bentley.GeometryNET.Polygon curvePrimitives = new Bentley.GeometryNET.Polygon(dPoint3Ds);
// 转为element后 存储到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取多边形边的个数,打印在消息框中
int res = curvePrimitives.GetPointCount();
System.Windows.Forms.MessageBox.Show("the points count of this polygon is " + res.ToString());
}
PointCountNoClosure()
功能说明:获取未闭合的点的个数
代码示例:
public void PointCountNoClosureTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用构造函数创建一个新的Polygon对象
Bentley.GeometryNET.Polygon curvePrimitives = new Bentley.GeometryNET.Polygon(dPoint3Ds);
// 转为element后 存储到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取多边形边未闭合点的个数,打印在消息框中
int res = curvePrimitives.PointCountNoClosure();
System.Windows.Forms.MessageBox.Show("the PointCountNoClosure of this polygon is " + res.ToString());
}
PointCountWithClosure()
功能说明:获取多边形闭合点的个数
代码示例:
public void PointCountWithClosureTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用构造函数创建一个新的Polygon对象
Bentley.GeometryNET.Polygon curvePrimitives = new Bentley.GeometryNET.Polygon(dPoint3Ds);
// 转为element后 存储到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取多边形边闭合点的个数,打印在消息框中
int res = curvePrimitives.PointCountWithClosure();
System.Windows.Forms.MessageBox.Show("the PointCountWithClosure of this polygon is " + res.ToString());
}
Points()
功能说明:获取多边形的点
代码示例:
public void PointsTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用构造函数创建一个新的Polygon对象
Bentley.GeometryNET.Polygon curvePrimitives = new Bentley.GeometryNET.Polygon(dPoint3Ds);
// 转为element后 存储到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取多边形边点,每个点和(0,0,1),做成线段 添加到model中
IEnumerable < DPoint3d > pointssss = curvePrimitives.Points();
foreach (var item in pointssss)
{
DSegment3d dSegment3D = new DSegment3d(item, new DPoint3d(0, 0, UorPerMas));
LineElement lineElement = new LineElement(dgnModel,null,dSegment3D);
lineElement.AddToModel();
}
}
PointsNoClosure()
功能说明:获取曲线没有闭合的点
代码示例:
public void PointsNoClosureTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用构造函数创建一个新的Polygon对象
Bentley.GeometryNET.Polygon curvePrimitives = new Bentley.GeometryNET.Polygon(dPoint3Ds);
// 转为element后 存储到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取多边形没有闭合的点,
//如果获取到的为空,则打印为空
//若不为空,每个点和(0,0,1),做成线段 添加到model中
IEnumerable<DPoint3d> pointssss = curvePrimitives.PointsNoClosure();
if (pointssss == null)
{
System.Windows.Forms.MessageBox.Show("this polygon has no PointsNoClosure" );
}
else
{
foreach (var item in pointssss)
{
DSegment3d dSegment3D = new DSegment3d(item, new DPoint3d(0, 0, UorPerMas));
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
}
}
PointsWithClosure()
功能说明:获取曲线闭合的点
代码示例:
public void PointsWithClosureTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//创建了点列表
List<DPoint3d> dPoint3Ds = new List<DPoint3d>();
dPoint3Ds.Add(new DPoint3d(0, 0, 0));
dPoint3Ds.Add(new DPoint3d(10000, 10000, 0));
dPoint3Ds.Add(new DPoint3d(20000, 60000, 0));
dPoint3Ds.Add(new DPoint3d(30000, -60000, 0));
dPoint3Ds.Add(new DPoint3d(40000, -10000, 0));
dPoint3Ds.Add(new DPoint3d(70000, 20000, 0));
dPoint3Ds.Add(new DPoint3d(90000, -40000, 0));
//使用构造函数创建一个新的Polygon对象
Bentley.GeometryNET.Polygon curvePrimitives = new Bentley.GeometryNET.Polygon(dPoint3Ds);
// 转为element后 存储到model中
Element element = DraftingElementSchema.ToElement(dgnModel, curvePrimitives, null);
element.AddToModel();
// 获取多边形闭合的点,
//如果获取到的为空,则打印为空
//若不为空,每个点和(0,0,1),做成线段 添加到model中
IEnumerable<DPoint3d> pointssss = curvePrimitives.PointsWithClosure();
if (pointssss == null)
{
System.Windows.Forms.MessageBox.Show("this polygon has no PointsWithClosure");
}
else
{
foreach (var item in pointssss)
{
DSegment3d dSegment3D = new DSegment3d(item, new DPoint3d(0, 0, UorPerMas));
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
}
}
ValidateConstruction()
功能说明:
代码示例:
属性:
IGeometry AsIGeometry { get; }
功能说明:
代码示例:
1.5.2.2.1.6 SurfacePatch
说明:
方法:
属性:
1.5.2.2.2 SingleLoopRegion
说明:
方法:
属性:
1.5.2.3 CurvePrimitiveCollection
说明:
方法:
属性:
1.5.2.3.1 ParityRegion
说明:
方法:
属性:
1.5.3 MSBsplineSurface
说明:B样条曲面相关的方法和属性
方法:
AddKnot()
功能说明:添加新的分界点
代码示例:
public void AddKnotTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//使用B样条曲面的addKnot方法,将结果转为element,添加到model中
surface.AddKnot(0.25, 2, 2);
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
}
AddTrimBoundary()
功能说明:使用添加边界剪切
代码示例:
public void AddTrimBoundaryTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
// 新建用于剪切的UV点列表
List<DPoint2d> dPoint2Ds = new List<DPoint2d>();
dPoint2Ds.Add(new DPoint2d(390750.34488501, 434084.915465823));
dPoint2Ds.Add(new DPoint2d(390295.975741524, 434498.21271185));
dPoint2Ds.Add(new DPoint2d(390315.975989623, 434064.530627409));
//使用添加边界剪切,转为element后添加到model中
surface.AddTrimBoundary(dPoint2Ds);
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
}
CleanKnots()
功能说明:清理所有非必要的分段点
代码示例:
public void CleanKnotsTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//清理所有不必要的分段点,然后转为element 添加到model中
surface.CleanKnots();
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
}
ClosestPoint()
功能说明:返回曲面上离空间点距离最近的点
代码示例:
public void ClosestPointTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//返回曲面上离空间点距离最近的点
surface.ClosestPoint(out DPoint3d xyz, out DPoint2d uv, new DPoint3d(390000, 430000, 37000));
//将曲面上离空间点最近点和空间点连起来做成线段,添加到model中
DSegment3d dSegment3D = new DSegment3d(xyz, new DPoint3d(390000, 430000, 37000));
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
CreateFromNative()
功能说明:从指针创建B样条曲面
代码示例:
CreateFromPoles(IList
knotVectorU, int orderU, int poleCountU, bool closedU, IList
功能说明:从关键点创建曲面
代码示例:
public void CreateFromPolesTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
}
CreateFromPoles(IList
功能说明:从关键点创建曲面
代码示例:
DereferenceToNative()
功能说明:获取曲面的指针
代码示例:
public void DereferenceToNativeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
// 获取曲面对象的指针, 将指针值打印在消息框中
IntPtr intPtr = MSBsplineSurface.DereferenceToNative(surface, true);
System.Windows.Forms.MessageBox.Show("IntPtr of this MSBsplineSurface is " + intPtr.ToString());
}
Dispose()
功能说明:释放内存
代码示例:
public void DisposeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//释放surface 占有的内存
surface.Dispose();
if (surface == null)
{
System.Windows.Forms.MessageBox.Show("the surface has been disposed");
}
}
ElevateDegree()
功能说明:在给定方向上增加曲面的度
代码示例:
public void ElevateDegreeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//在给定方向上增加曲面的度,将新的B样条曲面转为element,添加到model中
surface.ElevateDegree(3, 2);
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
}
FractionToKnot()
功能说明:返回指定方向上fraction值对应的knot值
代码示例:
public void FractionToKnotTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
// 返回指定方向上fraction值对应的knot值,打印在消息框中
double knot = surface.FractionToKnot(0.1, 2);
System.Windows.Forms.MessageBox.Show(" the knot value corresponding to 0.1 fraction and 2 direction is " + knot.ToString());
}
FractionToPoint(out DPoint3d xyz, double u, double v);
功能说明:返回曲面上的某点
代码示例:
public class FractionToPoint1
{
[EditorInfo("paddy wang", "2022.6.29")]
public void FractionToPointTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
// 返回曲面上的某点,将该点和原点连线,做成线段,添加到model中
surface.FractionToPoint(out DPoint3d dPoint3D, 0.1,0.1);
DSegment3d dSegment3D = new DSegment3d(dPoint3D, DPoint3d.Zero);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
FractionToPoint(out DPoint3d xyz, out DVector3d dPdU, out DVector3d dPdV, double u, double v);
功能说明:返回曲面上的某点和U V对应方向上的向量
代码示例:
public void FractionToPointTest2()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
// 返回曲面上的某点和U V对应方向上的向量,将该点和原点连线,做成线段,添加到model中
surface.FractionToPoint(out DPoint3d dPoint3D, out DVector3d dPdU, out DVector3d dPdV, 0.1, 0.1);
DSegment3d dSegment3D = new DSegment3d(dPoint3D, DPoint3d.Zero);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
FractionToPoint(out DPoint3d xyz, out DVector3d dPdU, out DVector3d dPdV, out DVector3d dPdUU, out DVector3d dPdVV, out DVector3d dPdUv, out DVector3d norm, double u, double v);
功能说明:返回曲面上的某点和U V对应方向上的向量,U V对应方向上的二阶向量和曲面上该点处的法向量
代码示例:
public void FractionToPointTest3()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
// 返回曲面上的某点和U V对应方向上的向量,U V对应方向上的二阶向量和曲面上该点处的法向量,将该点和原点连线,做成线段,添加到model中
surface.FractionToPoint(out DPoint3d dPoint3D, out DVector3d dPdU, out DVector3d dPdV, out DVector3d dPdUU, out DVector3d dPdVV, out DVector3d dPdUv, out DVector3d norm, 0.1, 0.1);
DSegment3d dSegment3D = new DSegment3d(dPoint3D, DPoint3d.Zero);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
GetKnotRange()
功能说明:返回指定方向上从fraction 0 到fraction 1之间最大和最小的knot值
代码示例:
public void GetKnotRangeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
surface.GetKnotRange(out double min, out double max, 2);
System.Windows.Forms.MessageBox.Show(" the min and max knot of the direction 2 is " + min.ToString()+ " " + max.ToString());
}
GetParameterRegion()
功能说明:返回b样条曲面的参数区域
代码示例:
public void GetParameterRegionTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//返回b样条曲面的参数区域,将获取到的参数化区域打印在消息框中
surface.GetParameterRegion(out double uMin, out double uMax, out double vMin, out double vMax);
System.Windows.Forms.MessageBox.Show(" the GetParameterRegion of this MSBsplineSurface is uMin " + uMin.ToString() + " uMax " + uMax.ToString()+ " vMin " + vMin.ToString()+ " vMax " + vMax.ToString());
}
GetPoleRange()
功能说明:返回曲面极点的范围
代码示例:
public void GetPoleRangeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
// 获取曲面极点的范围,将范围的低点、高点连起来,做成线段,添加到model中
DRange3d dRange3D = surface.GetPoleRange();
DSegment3d dSegment3D = new DSegment3d(dRange3D.High, dRange3D.Low);
LineElement lineElement = new LineElement(dgnModel, null, dSegment3D);
lineElement.AddToModel();
}
IsDegenerateEdge()
功能说明:检查曲面的边缘是否为单点
代码示例:
public void IsDegenerateEdgeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//判断曲面的第2个边界是否为单点,结果打印在消息框中
bool res = surface.IsDegenerateEdge(1, UorPerMas * 0.01);
System.Windows.Forms.MessageBox.Show("this edge of surface Is DegenerateEdge? " + res.ToString());
}
IsPhysicallyClosed()
功能说明:检查b样条曲面在任意一个参数方向上是否物理封闭。b样条曲面可能是非周期的,但如果它的第一行和最后一行 / 列极点重合,它仍然在v / u方向闭合。
代码示例:
public void IsPhysicallyClosedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//检查b样条曲面在任意一个参数方向上是否物理封闭,将结果打印在消息框中
surface.IsPhysicallyClosed(out bool closedU, out bool closedV);
System.Windows.Forms.MessageBox.Show("the surface IsPhysicallyClosed on the U direction? " + closedU.ToString() +
"\n\r the surface IsPhysicallyClosed on the V direction? " + closedV.ToString());
}
KnotToFraction()
功能说明:返回曲面上与knot相对应的fraction值
代码示例:
public void KnotToFractionTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
// 返回曲面上与knot相对应的fraction值,将结果打印在消息框中
double fraction = surface.KnotToFraction(0.466458403726642, 1);
System.Windows.Forms.MessageBox.Show("the fraction is " + fraction.ToString());
}
MakeBezier()
功能说明:生成等效的贝塞尔曲面
代码示例:
public void MakeBezierTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//生成等效的贝塞尔曲面,如果成功,将新的曲面转为element,添加到model中
bool res = surface.MakeBezier(surface);
if (res)
{
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
}
}
MakeClosed()
功能说明:设置曲面闭合
代码示例:
public void MakeClosedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//设置曲面闭合
bool res = surface.MakeClosed(1);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
}
MakeOpen()
功能说明:设置曲面不闭合
代码示例:
MakeRational()
功能说明:生成一个等价的有理b样条曲面
代码示例:
public void MakeRationalTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//生成一个等价的有理b样条曲面
bool res = surface.MakeRational();
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
}
MakeReversed()
功能说明:反向给定曲面的方向
代码示例:
public void MakeReversedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//反向给定曲面的方向
surface.MakeReversed(1);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
}
NormalizeKnotRange()
功能说明:缩放和转换曲面及其边界循环的参数范围,使所有参数都在0到1之间
代码示例:
public void NormalizeKnotRangeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//缩放和转换曲面及其边界循环的参数范围,使所有参数都在0到1之间。
surface.NormalizeKnotRange();
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
}
RemoveKnotsBounded()
功能说明:在容许误差范围内,移除所有可移除的knot
代码示例:
public void RemoveKnotsBoundedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//在容许误差范围内,移除所有可移除的knot
surface.RemoveKnotsBounded(1,0.001*UorPerMas);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
}
Resolution()
功能说明:得到b样条曲面的分辨率
代码示例:
public void ResolutionTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//得到b样条曲面的分辨率,打印在消息框中
double res = surface.Resolution();
System.Windows.Forms.MessageBox.Show("the resolution of this surface is " + res.ToString());
}
SetOuterBoundaryActive()
功能说明:将曲面的外部剪切边界设置为激活
代码示例:
public void SetOuterBoundaryActiveTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//设为true
surface.SetOuterBoundaryActive(true);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
//设为false
surface.SetOuterBoundaryActive(false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element2 = new BSplineSurfaceElement(dgnModel, null, surface);
element2.AddToModel();
}
SwapUV()
功能说明:交换曲面的U/V方向。
代码示例:
public void SetOuterBoundaryActiveTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//交换曲面的U / V方向。
surface.SwapUV();
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
}
Transform()
功能说明:曲面变换
代码示例:
public void TransformTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//曲面变换
DTransform3d dTransform3D = new DTransform3d(390750.34488501, 434084.915465823, 37030, 390956.642005217, 434312.083327423, 37029.9999999999, 390749.674146261, 434084.179271577, 37130);
surface.Transform(ref dTransform3D);
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element1 = new BSplineSurfaceElement(dgnModel, null, surface);
element1.AddToModel();
}
属性:
IsPlane { get; }
功能说明:判断曲面是否在某个平面内
代码示例:
public void IsPlaneTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 判断曲面是否在某个平面内
bool res = surface.IsPlane;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the surface is entirely within a plane " + res.ToString());
}
IsRational { get; }
功能说明:查询曲面是否有权重
代码示例:
public void IsRationalTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 查询曲面是否有权重
bool res = surface.IsRational;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the surface is rational or not " + res.ToString());
}
PoleCount { get; }
功能说明:查询曲面控制点的数量
代码示例:
public void PoleCountTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 查询曲面控制点的数量
int res = surface.PoleCount;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the pole count of this surface is " + res.ToString());
}
VKnotRange { get; }
功能说明:查询曲面V方向knot的范围
代码示例:
public void VKnotRangeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 查询曲面V方向knot的范围
DRange1d res = surface.VKnotRange;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the VKnotRange of this surface is :High " + res.High.ToString() + "Low " + res.Low.ToString());
}
VKnotCount { get; }
功能说明:查询曲面上V方向的knot数量
代码示例:
public void VKnotCountTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 查询曲面上V方向的knot数量
int res = surface.VKnotCount;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the VKnotCount of this surface is " + res.ToString());
}
VOrder { get; }
功能说明:查询曲面V方向的阶数
代码示例:
public void VOrderTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 查询曲面V方向的阶数
int res = surface.VOrder;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the VOrder of this surface is " + res.ToString());
}
VPoleCount { get; }
功能说明:查询曲面V方向的控制点个数
代码示例:
public void VPoleCountTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 查询曲面V方向的控制点个数
int res = surface.VPoleCount;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the VPoleCount os this surface is " + res.ToString());
}
IsVClosed { get; }
功能说明:查询曲面V方向是否闭合
代码示例:
public void IsVClosedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 查询曲面V方向是否闭合
bool res = surface.IsVClosed;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the surface is VClosed or not " + res.ToString());
}
UKnotRange { get; }
功能说明:查询曲面U方向knot的范围
代码示例:
public void UKnotRangeTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 查询曲面U方向knot的范围
DRange1d res = surface.UKnotRange;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the UKnotRange of this surface is :High " + res.High.ToString() + "Low " + res.Low.ToString());
}
UKnotCount { get; }
功能说明:查询曲面上U方向的knot数量
代码示例:
public void UKnotCountTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 查询曲面上U方向的knot数量
int res = surface.UKnotCount;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the UKnotCount of this surface is " + res.ToString());
}
UOrder { get; }
功能说明:查询曲面上U方向的阶数
代码示例:
public void UOrderTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 查询曲面上U方向的阶数
int res = surface.UOrder;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the UOrder of this surface is " + res.ToString());
}
UPoleCount { get; }
功能说明:查询曲面上U方向控制点个数
代码示例:
public void UPoleCountTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 查询曲面上U方向控制点个数
int res = surface.UPoleCount;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the UPoleCount of this surface is " + res.ToString());
}
IsUClosed { get; }
功能说明:查询曲面U方向是否闭合
代码示例:
public void IsUClosedTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 查询曲面U方向是否闭合
bool res = surface.IsUClosed;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the surface is UClosed or not " + res.ToString());
}
HoleOrigin { get; }
功能说明:查询B样条曲面参数边界是否参与剪切操作。返回值为true,表示曲面边界不是剪切边界;返回false,表示边界是剪切边界
代码示例:
public void HoleOriginTest1()
{
double UorPerMas = Session.Instance.GetActiveDgnModel().GetModelInfo().UorPerMaster;
DgnModel dgnModel = Session.Instance.GetActiveDgnModel();//获取当前激活的model
ModelInfo modelInfo = dgnModel.GetModelInfo();
//新建点列表
DPoint3d[] points = { new DPoint3d(390750.34488501, 434084.915465823, 37030), new DPoint3d(390956.642005217, 434312.083327423, 37029.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37029.9999999999), new DPoint3d(390502.640932221, 434725.045774041, 37029.9999999997), new DPoint3d(390295.975741524, 434498.21271185, 37029.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37029.9999999997), new DPoint3d(390315.975989623, 434064.530627409, 37029.9999999999), new DPoint3d(390542.641428419, 433857.68160516, 37030), new DPoint3d(390749.674146261, 434084.179271577, 37030), new DPoint3d(390750.34488501, 434084.915465823, 37130), new DPoint3d(390956.642005217, 434312.083327423, 37129.9999999999), new DPoint3d(390729.641468719, 434518.564550733, 37129.9999999999), new DPoint3d(390502.640932221, 434725.045774042, 37129.9999999996), new DPoint3d(390295.975741524, 434498.21271185, 37129.9999999997), new DPoint3d(390089.310550827, 434271.379649656, 37129.9999999996), new DPoint3d(390315.975989623, 434064.530627409, 37129.9999999999), new DPoint3d(390542.641428418, 433857.68160516, 37130), new DPoint3d(390749.674146261, 434084.179271577, 37130), };
//新建曲面的weight列表
List<double> weights = new List<double>() { 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, 1, 0.707393358053418, 1, 0.707393358053102, 1, 0.707393358053522, 1, 0.707393358053603, 1, };
//新建曲面U方向的分段点列表
List<double> uknots = new List<double>() { 0, 0, 0, 0.466458403726642, 0.466458403726642, 0.932916807453306, 0.932916807453306, 1.39937521117992, 1.39937521117992, 1.86583361490651, 1.86583361490651, 1.86583361490651, };
//新建曲面V方向的分段点列表
List<double> vknots = new List<double>() { 0, 0, 1, 1, };
//使用静态方法创建曲面
MSBsplineSurface surface = MSBsplineSurface.CreateFromPoles(
points,
weights,
uknots,
uknots.Count - 9,
9,
false,
vknots,
vknots.Count - 2,
2,
false,
false);
// 获取曲面边界是否参与剪切的属性
bool res = surface.HoleOrigin;
//将B样条曲面转为element,添加到model中
BSplineSurfaceElement element = new BSplineSurfaceElement(dgnModel, null, surface);
element.AddToModel();
//将结果打印在窗口中
System.Windows.Forms.MessageBox.Show("the surface parametric boundary in trim operations is " + res.ToString());
}
1.6 PolyfaceHeader
说明:
方法:
属性:
1.6.1 IndexedMesh
说明:
方法:
属性:
1.7 SingleLineText
说明:
方法:
属性: