两维变三维的问题
<P>目标:把建筑立面图转到各个平面上,然后组成简单的3维图。</P><P>过程:</P>
<P>1。先分析立面图所用的画图命令,然后针对各命令作旋转处理。</P>
<P>2。最简单的是画线命令,取得线的起终点,旋转坐标后,更新线的坐标就可以了。</P>
<P>3。对其他画图命令,因为autocad只在xy平面上画图,取得参数坐标后,先要用ucs命令转到对应平面,再画图。还要删除原来的图。</P>
<P>下面是一个转弧的例子。</P>
<P>生成弧的例程:</P>
<P>Sub Example_AddArc()<BR> ' This example creates an arc in model space.<BR> <BR> Dim arcObj As AcadArc<BR> Dim centerPoint(0 To 2) As Double<BR> Dim radius As Double<BR> Dim startAngleInDegree As Double<BR> Dim endAngleInDegree As Double<BR> <BR> ' Define the circle<BR> centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0#<BR> radius = 5#<BR> startAngleInDegree = 0#<BR> endAngleInDegree = 180#<BR> <BR> ' Convert the angles in degrees to angles in radians<BR> Dim startAngleInRadian As Double<BR> Dim endAngleInRadian As Double<BR> startAngleInRadian = startAngleInDegree * 3.141592 / 180#<BR> endAngleInRadian = endAngleInDegree * 3.141592 / 180#<BR> <BR> ' Create the arc object in model space<BR> Set arcObj = ThisDrawing.ModelSpace.AddArc(centerPoint, radius, startAngleInRadian, endAngleInRadian)<BR> ZoomAll<BR> <BR>End Sub</P>
<P>转弧的例程:</P>
<P>Sub myrotatearc()<BR> <BR> Dim newObjs As AcadArc<BR> Dim centerPoint(0 To 2) As Double<BR> Dim radius As Double<BR> Dim startAngleInDegree As Double<BR> Dim endAngleInDegree As Double<BR> Dim startAngleInRadian As Double<BR> Dim endAngleInRadian As Double<BR> <BR> Dim i, n As Long<BR> <BR> n = ThisDrawing.ModelSpace.Count<BR> <BR> For i = 0 To n - 1<BR> <BR> 'AcDbArc<BR> If ThisDrawing.ModelSpace.Item(i).ObjectName = "AcDbArc" Then<BR> <BR> Set newObjs = ThisDrawing.ModelSpace.Item(i)<BR> <BR> centerPoint(0) = newObjs.Center(0)<BR> centerPoint(1) = newObjs.Center(1)<BR> centerPoint(2) = newObjs.Center(2)<BR> <BR> radius = newObjs.radius<BR> startAngleInRadian = newObjs.StartAngle<BR> endAngleInRadian = newObjs.EndAngle<BR> <BR> ThisDrawing.SendCommand "_Ucs" & vbCr & "y" & vbCr & "90" & vbCr '绕y轴转90度<BR> <BR> Set arcObj = ThisDrawing.ModelSpace.AddArc(centerPoint, radius, startAngleInRadian - 3.1415926 / 2#, endAngleInRadian - 3.1415926 / 2#) '注意这里减了90度,可能是因为上面ucs命令转了90度<BR> <BR> <BR> ThisDrawing.SendCommand "_Ucs" & vbCr & "y" & vbCr & "-90" & vbCr '把画图平面转回来<BR> <BR> newObjs.Delete '删除原来的弧<BR> <BR> End If<BR> <BR> Next i<BR> <BR> ZoomAll<BR> <BR> ThisDrawing.Regen acAllViewports<BR> <BR> MsgBox "Good on ya!"<BR> <BR>End Sub</P> <P>学习了</P> 用rotate3d更简单。 用对齐命令更简单。
页:
[1]