乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 188|回复: 11

不同ucs中的圆柱体

[复制链接]

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-11-17 14:52:08 | 显示全部楼层 |阅读模式
好吧,我又难倒自己了 我试图定义一个新的ucs,并在该ucs而不是wcs中绘制一个圆柱体 这是我到目前为止的代码[代码我想我需要以某种方式改变我的坐标,但我从来没有这样做过,所以我该怎么做?
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-11-17 14:53:20 | 显示全部楼层
圆柱体使用这个变体是在WCS中,我认为这是我的问题
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-11-17 14:55:46 | 显示全部楼层
或者对于那些想要大局的人,我真正需要做的是
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-11-17 15:51:47 | 显示全部楼层
插入圆时,它将插入到世界坐标中,但它将采用当前ucs的法线。设置圆。法线为0,0,1,然后使用ucsmatrix变换圆
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-11-17 16:23:21 | 显示全部楼层
如果你只想画一个圆并挤出,继续…
…但是有一个圆柱体命令要求第一个端点中心和半径,然后提示;圆柱体或[另一端中心]的高度“;它允许您将另一端的中心放置在空间中的任何位置,而不考虑UCS 可能值得一次调查。
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-11-17 16:34:56 | 显示全部楼层
它真的很脏,但我的大脑正在关闭
这是可行的,但也有一些怪癖:
1-你选择一条定义圆柱体走向的线
2-你选择线的中点b/c圆柱体由质心放置
3-你必须选择线的第三个点(正交/极性开是件好事)
  1. Public Sub ucstest()
  2.     Dim origin As Variant
  3.     Dim xAxisPnt As Variant
  4.     Dim yAxisPnt(0 To 2) As Double
  5.     Dim ucsorigion(0 To 2) As Double
  6.     Dim objcyl As Acad3DSolid
  7.     Dim dblLength As Double
  8.     Dim objLine As AcadLine
  9.     Dim varpick As Variant
  10.     Dim obje As AcadEntity
  11.     ThisDrawing.Utility.GetEntity obje, varpick
  12.     Set objLine = obje
  13.     dblLength = objLine.Length
  14.     origin = Null
  15.     origin = ThisDrawing.Utility.GetPoint
  16.     xAxisPnt = ThisDrawing.Utility.GetPoint(origin)
  17.     Set objcyl = ThisDrawing.ModelSpace.AddCylinder(origin, 1, dblLength)
  18.     Dim ang As Double
  19.     ang = 90
  20.     ang = ang * 3.141592 / 180#
  21.     objcyl.Rotate3D origin, xAxisPnt, ang
  22. End Sub
周一需要进行更多清理
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-11-18 17:50:27 | 显示全部楼层
这里是#039;这是几个例子
前两个使用法线,第三个使用ucs
  1. Public Sub CylinderFromLine()
  2.     Dim oCyl As Acad3DSolid
  3.     Dim oCircle As AcadCircle
  4.     Dim oLine As AcadLine
  5.     Dim varpick As Variant
  6.     Dim Ent As AcadEntity
  7.     Dim N, oReg
  8.     Dim RegEnt(0) As AcadEntity
  9.     Dim V(2) As Double
  10.     Dim Unit As Double
  11.     Dim Vn(2) As Double
  12.     Dim P1, P2
  13.    
  14.     ThisDrawing.Utility.GetEntity Ent, varpick
  15.     If Not TypeOf Ent Is AcadLine Then Exit Sub
  16.     Set oLine = Ent
  17.    ' V = oLine.Delta 'Don't use the treacherous delta
  18.     P1 = oLine.StartPoint: P2 = oLine.EndPoint
  19.     V(0) = P2(0) - P1(0): V(1) = P2(1) - P1(1): V(2) = P2(2) - P1(2)
  20.    
  21.     'Normalise the vector(It's length=1)
  22.     Unit = Sqr(V(0) * V(0) + V(1) * V(1) + V(2) * V(2))
  23.     Vn(0) = V(0) / Unit: Vn(1) = V(1) / Unit: Vn(2) = V(2) / Unit
  24.    
  25.     Set oCircle = ThisDrawing.ModelSpace.AddCircle(oLine.StartPoint, 1)
  26.     oCircle.Normal = Vn
  27.     Set RegEnt(0) = oCircle
  28.     oReg = ThisDrawing.ModelSpace.AddRegion(RegEnt)
  29.     Set oCyl = ThisDrawing.ModelSpace.AddExtrudedSolid(oReg(0), oLine.Length, 0)
  30. End Sub
  31. Public Sub CylinderFromPoints()
  32.     'this mimics the Cylinder command
  33.     Dim oCyl As Acad3DSolid
  34.     Dim oCircle As AcadCircle
  35.     Dim Rad As Double
  36.     Dim P1, P2
  37.     Dim N, oReg
  38.     Dim dLength As Double
  39.     Dim RegEnt(0) As AcadEntity
  40.     Dim Util As AcadUtility
  41.    
  42.     Set Util = ThisDrawing.Utility
  43.     P1 = Util.GetPoint(, "Specify center point for base of cylinder:")
  44.     Rad = Util.GetDistance(ToUcs(P1), "Specify radius for base of cylinder:")
  45.     P2 = ThisDrawing.Utility.GetPoint(ToUcs(P1), "Specify center of other end of cylinder:")
  46.     Dim V(2) As Double
  47.     V(0) = P2(0) - P1(0): V(1) = P2(1) - P1(1): V(2) = P2(2) - P1(2)
  48.     Dim Unit As Double
  49.     Dim Vn(2) As Double
  50.     'Normalise the vector(It's length=1)
  51.     Unit = Sqr(V(0) * V(0) + V(1) * V(1) + V(2) * V(2))
  52.     Vn(0) = V(0) / Unit: Vn(1) = V(1) / Unit: Vn(2) = V(2) / Unit
  53.    
  54.     dLength = Sqr(V(0) ^ 2 + V(1) ^ 2 + V(2) ^ 2)
  55.     Set oCircle = ThisDrawing.ModelSpace.AddCircle(P1, Rad)
  56.     oCircle.Normal = Vn
  57.     Set RegEnt(0) = oCircle
  58.     oReg = ThisDrawing.ModelSpace.AddRegion(RegEnt)
  59.     Set oCyl = ThisDrawing.ModelSpace.AddExtrudedSolid(oReg(0), dLength, 0)
  60. End Sub
  61. Public Sub CylinderFromUcs()
  62.     Dim oUcs As AcadUCS
  63.     Dim Orig As Variant
  64.     Dim xAxisPnt(0 To 2) As Double
  65.     Dim yAxisPnt(0 To 2) As Double
  66.     Dim oCyl As Acad3DSolid
  67.    
  68.     Orig = ThisDrawing.Utility.GetPoint
  69.     Set oCyl = ThisDrawing.ModelSpace.AddCylinder(Zero, 1, 3)
  70.     ' Define the UCS
  71.     xAxisPnt(0) = 0: xAxisPnt(1) = 0: xAxisPnt(2) = -1
  72.     yAxisPnt(0) = 0: yAxisPnt(1) = 1: yAxisPnt(2) = 0
  73.     Set oUcs = ThisDrawing.UserCoordinateSystems.Add(Zero, xAxisPnt, yAxisPnt, "New_UCS")
  74.     oUcs.origin = Orig
  75.     oCyl.TransformBy oUcs.GetUCSMatrix
  76. End Sub
  77. Function ToUcs(pt As Variant) As Variant
  78.     ToUcs = ThisDrawing.Utility.TranslateCoordinates(pt, acWorld, acUCS, False)
  79. End Function
  80.    
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-11-20 12:32:54 | 显示全部楼层
布莱科,这些很好用&nbsp
;现在,你能解释一下发生了什么吗?这样我就知道发生了什么,这样我就可以在将来使用它了 干得好。
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-11-20 12:59:26 | 显示全部楼层
谢谢你。我本打算写一篇关于这方面的文章,但它'这需要一点时间
对于圆柱体以外的对象,请注意Ucs方法,由于某些原因,圆柱体的工作原理与其他实体略有不同
“帮助说”;创建一个三维实体圆柱体,其底部位于WCS的XY平面上&引用;通常,在世界中插入一些东西,确保法线为0,0,1,然后将其转换为所需的ucs(或矩阵)
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-11-20 15:36:13 | 显示全部楼层
Bryco,我再次喜欢你的代码,谢谢你的优雅(雅达)'J#039&书信电报;
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-7-7 00:37 , Processed in 0.724444 second(s), 83 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表