三维效果如何实现?
<DIV>我想将下图中的管线用VBA以三维形式显示,如在图上画一条线与其相交的管线以三维开式显示,也就是剖面图那种效果,可不知该如下下手?下图中每条管线都有属性信息,(如管径\埋深...),井位有坐标信息</DIV><DIV> </DIV> 简单点说就是图上有多条直线,Z坐标都不为零,我想用三维显示。并且有些显示方的,有些是圆的。请问斑主用VBA该怎么做? 如果想创建圆柱体,RetVal = object.AddCylinder(Center, Radius, Height) 它的参数就这三个,那我有多条直线本来是相交的,但变成柱体后不得变成平行了?熟悉3D操作的朋友麻烦你们也指点一下。谢谢 楼主公司是做地下管线探测的?在哪?
可以用AddRegion先构成一个矩形的面,然后用AddRevolvedSolid旋转所构成的面,就可以得到一个三维管线了 <DIV>是啊,我们是搞测绘的,我们现在开始做管线方面的工作.yulijin608你也搞这方面的吧?</DIV>
<DIV>有机会多向你学习.我先试试</DIV>
<DIV> </DIV> <DIV>为什么我这么旋转不好用呢?</DIV>
<DIV>Sub test()<BR> Dim curves(0 To 3) As AcadEntity</DIV>
<DIV> </DIV>
<DIV> <BR> ' This example adds a line in model space<BR> <BR> Dim lineObj As AcadLine<BR> Dim startPoint(0 To 2) As Double<BR> Dim endPoint(0 To 2) As Double<BR> <BR> ' Define the start and end points for the line<BR> startPoint(0) = 1#: startPoint(1) = 1#: startPoint(2) = 0#<BR> endPoint(0) = 5#: endPoint(1) = 5#: endPoint(2) = 0#<BR> <BR> 'Á¬½Ó³É·â±ÕÇøÓò<BR> Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)<BR> Dim offsetobj As Variant<BR> offsetobj = lineObj.Offset(0.25)<BR> Set curves(0) = lineObj<BR> Set curves(1) = offsetobj(0)<BR> Set curves(2) = ThisDrawing.ModelSpace.AddLine(lineObj.startPoint, offsetobj(0).startPoint)<BR> Set curves(3) = ThisDrawing.ModelSpace.AddLine(lineObj.endPoint, offsetobj(0).endPoint)<BR> <BR> ' Create the region<BR> Dim regionObj As Variant<BR> regionObj = ThisDrawing.ModelSpace.AddRegion(curves)<BR> regionObj(0).Color = acCyan<BR> ZoomAll<BR> MsgBox "Revolve the region to create the solid.", , "AddRevolvedSolid Example"<BR> <BR> ' Define the rotation axis<BR> Dim axisPt(0 To 2) As Double<BR> Dim axisDir(0 To 2) As Double<BR> Dim angle As Double<BR> axisPt(0) = 5: axisPt(1) = 5: axisPt(2) = 0<BR> axisDir(0) = 11: axisDir(1) = 1: axisDir(2) = 3<BR> angle = 0.785<BR> <BR> ' Create the solid<BR> Dim solidObj As Acad3DSolid<BR> Set solidObj = ThisDrawing.ModelSpace.AddRevolvedSolid(regionObj(0), axisPt, axisDir, angle)<BR> solidObj.Color = acRed<BR> ZoomAll<BR> <BR> ' Change the viewing direction of the viewport<BR> Dim NewDirection(0 To 2) As Double<BR> NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1<BR> ThisDrawing.ActiveViewport.Direction = NewDirection<BR> ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport<BR> ZoomAll<BR> MsgBox "Solid created.", , "AddRevolvedSolid Example"</DIV>
<DIV> </DIV>
<DIV>End Sub</DIV>
<DIV> </DIV>
<DIV> </DIV> 应当是旋转轴的问题, Set solidObj = ThisDrawing.ModelSpace.AddRevolvedSolid(regionObj(0), lineObj.startPoint, lineObj.endPoint, 6.28) '6.28表示旋转一周<BR> AddRevolvedSolid出错,怪了我就只是把示例改了一点就不行了
页:
[1]