明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1317|回复: 7

通过旋转创建三维(不是灌水!!!)

[复制链接]
发表于 2004-8-24 10:01:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2004-8-24 10:41:26 编辑

请教 通过旋转创建三维,将region对象A桡经过P1(X1,Y1,H1)和P2(X2,Y2,H2)两点的直线L旋转一周用下面函数对吗?
Set solidObj = ThisDrawing.ModelSpace.AddRevolvedSolid(A, P1, P2, 6.28) 为什么老创建出圆锥形实体? 致谢

评分

参与人数 1金钱 -5 贡献 -1 激情 -2 收起 理由
雪山飞狐_lzh -5 -1 -2 【差评】灌水

查看全部评分

 楼主| 发表于 2004-8-24 10:39:00 | 显示全部楼层
老大,不是灌水,我试验3天了,region对象A是矩形,直线L平行于A的一条边,我理解应旋转出一圆管型实体,但是老创建出圆锥形,求解!!!!
发表于 2004-8-24 11:56:00 | 显示全部楼层
你先灌水了,开始是什么? rrrr


把完整的代码贴上来
 楼主| 发表于 2004-8-24 16:46:00 | 显示全部楼层
Sub view_3d() 'On Error Resume Next

Dim sset As AcadSelectionSet
Dim seledobj As Object ThisDrawing.SelectionSets("SS1").Delete
Set sset = ThisDrawing.SelectionSets.Add("SS1")
On Error GoTo 0
DoEvents
sset.SelectOnScreen
'================================================ ' Dim sset As Object
' Set sset = ThisDrawing.SelectionSets.Item("SS1")
Dim ent As AcadEntity

For Each ent In sset
If TypeName(ent) = "IAcadLine" Then
S_P = ent.StartPoint
e_p = ent.EndPoint
ang = ent.angle
houdu = 0.1
AddRevolvedSolid S_P(0), S_P(1), S_P(2), e_p(0), e_p(1), e_p(2), ang, 500, houdu
End If
Next ent End Sub Sub AddRevolvedSolid(ByVal x1 As Double, ByVal y1 As Double, ByVal h1 As Double, _
ByVal x2 As Double, ByVal y2 As Double, ByVal h2 As Double, _
ByVal jiaodu As Double, _
banjing As Double, _
ByVal houdu As Double)
linex1 = x1: liney1 = y1: lineh1 = h1
linex2 = x2: liney2 = y2: lineh2 = h2



x1 = linex1 + banjing * Sin(jiaodu): y1 = liney1 - banjing * Cos(jiaodu): h1 = lineh1
x2 = linex2 + banjing * Sin(jiaodu): y2 = liney2 - banjing * Cos(jiaodu): h2 = lineh2

' This example creates a solid from a region
' rotated around an axis.
' The region is created from an arc and a line.
Dim curves(0 To 3) As AcadEntity
' Define the line Dim start_p(0 To 2) As Double
Dim end_p(0 To 2) As Double
Dim radius As Double
Dim startAngle As Double
Dim endAngle As Double


start_p(0) = x1: start_p(1) = y1: start_p(2) = h1
end_p(0) = x2: end_p(1) = y2: end_p(2) = h2
Set curves(0) = ThisDrawing.ModelSpace.AddLine(start_p, end_p) start_p(0) = x2: start_p(1) = y2: start_p(2) = h2
end_p(0) = x2 - houdu * Sin(jiaodu): end_p(1) = y2 + houdu * Cos(jiaodu): end_p(2) = h2
Set curves(1) = ThisDrawing.ModelSpace.AddLine(start_p, end_p) start_p(0) = x2 - houdu * Sin(jiaodu): start_p(1) = y2 + houdu * Cos(jiaodu): start_p(2) = h2
end_p(0) = x1 - houdu * Sin(jiaodu): end_p(1) = y1 + houdu * Cos(jiaodu): end_p(2) = h1
Set curves(2) = ThisDrawing.ModelSpace.AddLine(start_p, end_p) start_p(0) = x1 - houdu * Sin(jiaodu): start_p(1) = y1 + houdu * Cos(jiaodu): start_p(2) = h1
end_p(0) = x1: end_p(1) = y1: end_p(2) = h1
Set curves(3) = ThisDrawing.ModelSpace.AddLine(start_p, end_p)


' Create the region
Dim regionObj As Variant
regionObj = ThisDrawing.ModelSpace.AddRegion(curves)
regionObj(0).Color = acCyan
' MsgBox "Revolve the region to create the solid.", , "AddRevolvedSolid Example"

' Define the rotation axis
Dim axisPt(0 To 2) As Double
Dim axisDir(0 To 2) As Double
Dim angle As Double
axisPt(0) = linex1: axisPt(1) = liney1: axisPt(2) = lineh1

axisDir(0) = linex2: axisDir(1) = liney2: axisDir(2) = lineh2
angle = 6.28

' Create the solid
Dim solidObj As Acad3DSolid
Set solidObj = ThisDrawing.ModelSpace.AddRevolvedSolid(regionObj(0), axisPt, axisDir, angle)
solidObj.Color = acRed
' ' Change the viewing direction of the viewport
' Dim NewDirection(0 To 2) As Double
' NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1
' ThisDrawing.ActiveViewport.Direction = NewDirection
' ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
' ZoomAll
' MsgBox "Solid created.", , "AddRevolvedSolid Example" End Sub 画一条三维直线试验 老大,看看是不是思想问题
发表于 2004-8-24 21:35:00 | 显示全部楼层

RetVal = object.AddRevolvedSolid(Profile, AxisPoint, AxisDir, Angle)

Object

MSITStore:D:\Program%20Files\AutoCAD%202005\help\acadauto.chm::/idh_modelspace_collection.htm" target="_blank" >ModelSpace Collection, MSITStore:D:\Program%20Files\AutoCAD%202005\help\acadauto.chm::/idh_paperspace_collection.htm" target="_blank" >PaperSpace Collection, MSITStore:D:\Program%20Files\AutoCAD%202005\help\acadauto.chm::/idh_block_object.htm" target="_blank" >Block
The object or objects this method applies to.

Profile

MSITStore:D:\Program%20Files\AutoCAD%202005\help\acadauto.chm::/idh_region_object.htm" target="_blank" >Region object; input-only

AxisPoint
Variant (three-element array of doubles); input-only
The 3D WCS coordinates specifying the start point of the axis of revolution.
AxisDir
Variant (three-element array of doubles); input-only
A 3D vector specifying the direction of the axis of revolution.

Angle

Double; input-only
The angle of revolution in radians. Enter 6.28 for a full circle revolution.

RetVal

MSITStore:D:\Program%20Files\AutoCAD%202005\help\acadauto.chm::/idh_3dsolid_object.htm" target="_blank" >3DSolid object
A 3DSolid object as the newly created revolved solid.

 楼主| 发表于 2004-8-25 11:52:00 | 显示全部楼层
RetVal = object.AddRevolvedSolid(Profile, AxisPoint, AxisDir, Angle)
帮助我看过了AxisPoint是旋转轴起点, AxisDir是旋转轴方向点,对于将region对象A桡经过P1(X1,Y1,H1)和P2(X2,Y2,H2)两点的直线L旋转一周不是Set solidObj = ThisDrawing.ModelSpace.AddRevolvedSolid(A, P1, P2, 6.28) 吗? 完整代码第四楼,能帮我试试吗?实在没辙了
发表于 2004-8-25 13:47:00 | 显示全部楼层
p2(x2-x1,y2-y1,z2-z1)
 楼主| 发表于 2004-8-25 14:19:00 | 显示全部楼层
太感谢了,向无私奉献的人致敬
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-28 02:45 , Processed in 0.195486 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表