代码生的complexshape 为什么咋不能用
Sub test() Dim tr As Transform3d Dim cpt As Point3d Dim pt1 As Point3d Dim pt2 As Point3d Dim ming(11) As ChainableElement Dim myArc As ArcElement Dim myLine As LineElement Dim viewindex As Integer viewindex = CommandState.LastView.index Dim pts(0 To 15) As Point3d pts(0) = Point3dFromXYZ(0, 6.45, 0) pts(1) = Point3dFromXYZ(0, 6.45, -0.25) pts(2) = Point3dFromXYZ(0, 3.641282143, -0.630843099) pts(3) = Point3dFromXYZ(0, 3.668154877, -0.829029517) pts(4) = Point3dFromXYZ(0, 3.472038742, -0.78980629) pts(5) = Point3dFromXYZ(0, 3.036077677, -2.969611614) pts(6) = Point3dFromXYZ(0, 2.93801961, -2.95) pts(7) = Point3dFromXYZ(0, 2.93801961, -3.05) pts(15) = Point3dFromXYZ(0, -6.45, 0) pts(14) = Point3dFromXYZ(0, -6.45, -0.25) pts(13) = Point3dFromXYZ(0, -3.641282143, -0.630843099) pts(12) = Point3dFromXYZ(0, -3.668154877, -0.829029517) pts(11) = Point3dFromXYZ(0, -3.472038742, -0.78980629) pts(10) = Point3dFromXYZ(0, -3.036077677, -2.969611614) pts(9) = Point3dFromXYZ(0, -2.93801961, -2.95) pts(8) = Point3dFromXYZ(0, -2.93801961, -3.05) cpt = Point3dFromXYZ(1, 1, 0) pt1 = Point3dFromXYZ(0, 1, 0) pt2 = Point3dFromXYZ(1, 0, 0) Set myLine = CreateLineElement2(Nothing, pts(0), pts(1)) Set ming(0) = myLine Set myLine = CreateLineElement2(Nothing, pts(1), pts(2)) Set ming(1) = myLine Set myArc = CreateArcElement1(Nothing, pts(4), pts(3), pts(2)) Set ming(2) = myArc Set myLine = CreateLineElement2(Nothing, pts(4), pts(5)) Set ming(3) = myLine Set myArc = CreateArcElement1(Nothing, pts(5), pts(6), pts(7)) Set ming(4) = myArc Set myLine = CreateLineElement2(Nothing, pts(7), pts(8)) Set ming(5) = myLine Set myArc = CreateArcElement1(Nothing, pts(8), pts(9), pts(10)) Set ming(6) = myArc Set myLine = CreateLineElement2(Nothing, pts(10), pts(11)) Set ming(7) = myLine Set myArc = CreateArcElement1(Nothing, pts(13), pts(12), pts(11)) Set ming(8) = myArc Set myLine = CreateLineElement2(Nothing, pts(13), pts(14)) Set ming(9) = myLine Set myLine = CreateLineElement2(Nothing, pts(14), pts(15)) Set ming(10) = myLine Set myLine = CreateLineElement2(Nothing, pts(15), pts(0)) Set ming(11) = myLine Dim oComplexShape1 As ComplexShapeElement Set oComplexShape1 = CreateComplexShapeElement1(ming, msdFillModeNotFilled) ActiveModelReference.AddElement oComplexShape1 CommandState.StartDefaultCommand End Sub
下图所示的地方有点问题,构造拉伸体时,轮廓必须是一个闭合的一个Shape,不能有自交的情况发生。
Answer Verified By: 鸣 崔
谢谢,麻烦再问一下 Set myArc = CreateArcElement1(Nothing, pts(4), pts(3), pts(2)) 生成的弧为什么会成这个样子
生成复杂链的时候,每段一定要是首尾依次相连,否则函数里边自动生成一条线段将前后两端连接起来。这里是因为您这个弧的起点和终点弄反了,所以生成复杂链的时候就会多出来一条线,但是如果您仅仅是调整一下传递给CreateArcElement1的两个点的话,又会出现生成劣弧还是优弧不确定的情况,所以您这里最好是改成CreateArcElement3,这个是需要弧的起点和终点,以及弧上边的一点。
非常感谢,问题已解决