cangcang 发表于 2005-12-4 09:59:00

能不能创建一个面沿一个组合曲线路径拉伸成三维实体

<P>Private Sub Command3_Click()<BR>Call AutoCAD_Appliaction(Form1, AcadApp, AcadDoc)<BR>&nbsp;&nbsp;&nbsp; Dim r, h, b, L1, L2, W, baseX, baseY, baseZ As Double<BR>&nbsp;&nbsp;&nbsp; r = 15<BR>&nbsp;&nbsp;&nbsp; h = 10<BR>&nbsp;&nbsp;&nbsp; b = 3<BR>&nbsp;&nbsp;&nbsp; W = 80<BR>&nbsp;&nbsp;&nbsp; L1 = 100<BR>&nbsp;&nbsp;&nbsp; L2 = 100<BR>&nbsp;&nbsp;&nbsp; baseX = 300<BR>&nbsp;&nbsp;&nbsp; baseY = 100<BR>&nbsp;&nbsp;&nbsp; baseZ = 100<BR>&nbsp;&nbsp;&nbsp; Dim curves(0 To 2) As Object<BR>&nbsp;&nbsp;&nbsp; Dim curves1(0 To 3) As AcadEntity<BR>&nbsp;&nbsp; 'r :内径, h: 板厚,&nbsp; b:接逢间隙,l:中心距半长<BR>&nbsp;&nbsp;&nbsp; Dim basePoint(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim basePoint1(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim basePoint2(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp;&nbsp; Dim basePoint3(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim point1(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim point2(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim point3(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim pi As Double<BR>&nbsp;&nbsp;&nbsp; Dim startAngle, endAngle As Double<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; pi = 3.141592<BR>&nbsp;&nbsp;&nbsp; basePoint(0) = baseX: basePoint(1) = baseY: basePoint(2) = baseZ<BR>&nbsp;&nbsp;&nbsp; basePoint1(0) = baseX + L1 + L2: basePoint1(1) = baseY: basePoint1(2) = baseZ<BR>&nbsp;&nbsp;&nbsp; basePoint2(0) = baseX + L1 + L2: basePoint1(1) = baseY: basePoint1(2) = baseZ<BR>&nbsp;&nbsp;&nbsp; point1(0) = baseX + L1 + L2: point1(1) = baseY - r: point1(2) = baseZ<BR>&nbsp;&nbsp;&nbsp; point2(0) = baseX + L1 + L2: point2(1) = baseY - r - h: point2(2) = baseZ<BR>&nbsp;&nbsp;&nbsp; point3(0) = baseX: point3(1) = baseY - r - h: point3(2) = baseZ + 60<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; startAngle = -(pi / 2 - Atn(Sqr((r + h / 2) * (r + h / 2) - ((r + h / 2) - b) * ((r + h / 2) - b)) / ((r + h / 2) - b))) '计算内圆接头的起始角度<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; endAngle = (pi * 3) / 2 '计算到切点的角度<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Set curves(0) = AcadApp.ActiveDocument.ModelSpace.AddArc(basePoint, (r + h / 2), startAngle, endAngle)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' Define the line<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; startAngle = -pi / 2 '计算内圆接头的起始角度<BR>&nbsp;&nbsp;&nbsp; endAngle = (pi * 3) / 2 - Atn(Sqr(r * r - (r - b) * (r - b)) / (r - b)) '计算到切点的角度<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; Set curves(1) = AcadApp.ActiveDocument.ModelSpace.AddArc(basePoint1, (r + h / 2), startAngle, endAngle)<BR>&nbsp;&nbsp; Set curves(2) = AcadApp.ActiveDocument.ModelSpace.AddLine(curves(0).EndPoint, curves(1).StartPoint)<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; basePoint2(0) = baseX - W - h / 2: basePoint2(1) = baseY - r - h / 2 + b: basePoint2(2) = baseZ '+ Sqr((r + h / 2) * (r + h / 2) - (r + h / 2 - b) * (r + h / 2 - b))<BR>&nbsp;&nbsp;&nbsp; basePoint3(0) = baseX + W + h / 2: basePoint3(1) = baseY - r - h / 2 + b: basePoint3(2) = baseZ '+ Sqr((r + h / 2) * (r + h / 2) - (r + h / 2 - b) * (r + h / 2 - b))<BR>&nbsp;&nbsp;&nbsp; Set curves1(0) = AcadApp.ActiveDocument.ModelSpace.AddArc(basePoint2, h / 2, -pi / 2, pi / 2)<BR>&nbsp;&nbsp;&nbsp; Set curves1(1) = AcadApp.ActiveDocument.ModelSpace.AddArc(basePoint2, h / 2, pi / 2, (pi * 3) / 2)<BR>&nbsp;&nbsp;&nbsp; Set curves1(2) = AcadApp.ActiveDocument.ModelSpace.AddLine(curves1(0).EndPoint, curves1(1).StartPoint)<BR>&nbsp;&nbsp;&nbsp; Set curves1(3) = AcadApp.ActiveDocument.ModelSpace.AddLine(curves1(1).EndPoint, curves1(0).StartPoint)<BR>&nbsp;&nbsp;&nbsp; ' Create the region<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim regionObj As Variant<BR>&nbsp;&nbsp;&nbsp;&nbsp; Dim regionObj1 As Variant<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; ' regionObj1 = AcadApp.ActiveDocument.ModelSpace.AddRegion(curves1)<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' Create the solid<BR>&nbsp;&nbsp;&nbsp; Dim solidObj, solidObj1 As Acad3DSolid<BR>&nbsp;&nbsp;&nbsp; Set solidObj = AcadApp.ActiveDocument.ModelSpace.AddExtrudedSolidAlongPath(regionObj1(0), curves(0))<BR>&nbsp;&nbsp;&nbsp; 'Set solidObj1 = AcadApp.ActiveDocument.ModelSpace.AddExtrudedSolid(regionObj1(0), W, 0)<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; </P>
<P>&nbsp;&nbsp; Call AutoCAD_3DView(1, 1, -0.5, AcadApp)‘调用模块<BR>&nbsp;&nbsp; AcadApp.ActiveDocument.SendCommand "shademode" &amp; vbCr &amp; "G" &amp; vbCr<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp; AcadApp.ZoomAll<BR>&nbsp;&nbsp; Dim strPath As String<BR>&nbsp;&nbsp; strPath = "d:\jpg\jpg1"<BR>&nbsp;&nbsp; Call Export_Picture(strPath, AcadApp)<BR>End Sub</P>
<P>问题:1、拉伸路径能不能为一个半圆弧加一条直线和另外一个半圆弧组成的曲线,</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2、用addarc命令能能创建一个YZ面上的半圆弧</P>

yueyaer 发表于 2005-12-4 10:07:00

<P>可以啊,你可以使用系统提供的AddExtrudedSolidAlongPath,第一个参数是要拉伸的截面,第二个参数是拉伸的路径,可以创建出一个实体</P>

cangcang 发表于 2005-12-4 12:50:00

<P>问题是第二点怎样画在YZ(相当左视上)面上的半圆弧</P>
<P>&nbsp;</P>
页: [1]
查看完整版本: 能不能创建一个面沿一个组合曲线路径拉伸成三维实体