乐筑天下

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

零海拔。

[复制链接]

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-6-1 09:53:40 | 显示全部楼层 |阅读模式
我找不到一个正常的区域来写作,acad 2006。我知道区域是愚蠢的,但是看起来它们是一个平面实体,并且可以假设一个单一的法线。我正在创建一个sub来发送所有的东西到zero z,到目前为止,这是第一个不能正常读/写的实体。
昏暗看起来也很棘手。

本帖以下内容被隐藏保护;需要你回复后,才能看到!

游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

16

主题

168

帖子

39

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
197
发表于 2006-6-1 11:54:30 | 显示全部楼层
我曾经写过这个,但它不涉及区域或维度
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-6-1 12:56:04 | 显示全部楼层
谢谢亚利桑那州,我一直在做和你完全相同的事情,但是添加一个正常的检查,就好像说一个圆圈在倾斜时,我宁愿手动设置它,或者如果reqd.做一个椭圆,而不是把它设置为零。正常大部分时间效果很好。这一定是区域的错误。
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-6-2 09:45:08 | 显示全部楼层
是否有人成功地将dim展平,或者我需要使用lisp?
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-6-4 12:23:39 | 显示全部楼层

我想这是一个徒劳无益的事业。
什么是维度?
这就像一个名称以*d开头的块引用,在vba中是找不到的
尺寸块有很多有用的信息,
(开始、结束和尺寸线点),但是对块(如属性)的更新似乎不会更新尺寸。
因此,我似乎必须创建一个新的维度和新的块,因为块只能使用一次。-(希望这是错误的)
使用getxdata->setxdata可以轻松复制扩展数据(所有dimstyle覆盖都在这里)
每当将dim附加到对象时,extensiondictionary中都有1个项目,而不是单击屏幕上的2个空点。然而,该项目是空的,而不是放弃说,对象句柄或id,这将是方便的。
回复

使用道具 举报

71

主题

928

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1230
发表于 2006-6-4 14:18:15 | 显示全部楼层
Bryco,
因为我不怎么使用3d,你能不能贴一张你想做的之前和之后对象的样图?我相信你已经涵盖了所有的基础知识,但有时让别人看着和你一样的东西会有所帮助。
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-6-4 14:29:19 | 显示全部楼层
这是一个非常简单的绘图。昏暗在世界ucs中很好,但是起点和终点在它的高度接触到多边形。我想将这些点设置为z=0,并保持一致性。
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-6-4 14:38:16 | 显示全部楼层

现在,如果你拉伸一个多边形顶点,dim会完美调整,而如果你移动一个顶点,dim会在elev中向下移动。
  1. Sub Flatten()
  2.     Dim Ent As AcadEntity
  3.     Dim obj As AcadEntity
  4.     Dim oLine As AcadLine
  5.     Dim oMline As AcadMLine
  6.     Dim oCirc As AcadCircle
  7.     Dim oArc As AcadArc
  8.     Dim oEll As AcadEllipse
  9.     Dim oPline As AcadLWPolyline
  10.     Dim oHatch As AcadHatch
  11.     Dim oSpline As AcadSpline
  12.     Dim oReg As AcadRegion
  13.     Dim oPoint As AcadPoint
  14.     Dim oBref As AcadBlockReference
  15.     Dim oMt As AcadMText
  16.     Dim oLeader As AcadLeader
  17.     Dim Atts, Att
  18.     Dim P1, P2, P3
  19.     Dim Min, Max
  20.     Dim Zero(2) As Double, El(2) As Double
  21.    
  22.     For Each Ent In ThisDrawing.ModelSpace
  23.         If TypeOf Ent Is AcadLine Then
  24.             Set oLine = Ent
  25.             oLine.StartPoint = Z0(oLine.StartPoint)
  26.             oLine.EndPoint = Z0(oLine.EndPoint)
  27.             If oLine.Length = 0 Then oLine.Delete
  28.         End If
  29.         If TypeOf Ent Is AcadMLine Then
  30.             Set oMline = Ent
  31.             P1 = oMline.Coordinates
  32.             If P1(2) = P1(5) Then
  33.                 El(2) = P1(2)
  34.                 oMline.Move El, Zero
  35.             End If
  36.    
  37.         End If
  38.         
  39.         If TypeOf Ent Is AcadCircle Then
  40.             Set oCirc = Ent
  41.             If N1(oCirc) Then
  42.                 oCirc.Center = Z0(oCirc.Center)
  43.             End If
  44.         End If
  45.         If TypeOf Ent Is AcadArc Then
  46.             Set oArc = Ent
  47.             If N1(oArc) Then
  48.                 oArc.Center = Z0(oArc.Center)
  49.             End If
  50.         End If
  51.         If TypeOf Ent Is AcadEllipse Then
  52.             Set oEll = Ent
  53.             If N1(oEll) Then
  54.                 oEll.Center = Z0(oEll.Center)
  55.             End If
  56.         End If
  57.         If TypeOf Ent Is AcadLWPolyline Then
  58.             Set oPline = Ent
  59.             If N1(oPline) Then
  60.                 oPline.Elevation = 0
  61.             End If
  62.         End If
  63.         If TypeOf Ent Is AcadHatch Then
  64.             Set oHatch = Ent
  65.             If N1(oHatch) Then
  66.                 oHatch.Elevation = 0
  67.             End If
  68.         End If
  69.         If TypeOf Ent Is AcadSpline Then
  70.             Set oSpline = Ent
  71.             If oSpline.IsPlanar Then
  72.                 P1 = oSpline.FitPoints
  73.                 If P1(2) = P1(5) Then
  74.                     El(2) = P1(2)
  75.                     oSpline.Move El, Zero
  76.                 End If
  77.             End If
  78.         End If
  79.         If TypeOf Ent Is Acad3DPolyline Then
  80.             Dim oP3 As Acad3DPolyline
  81.             'yada
  82.         End If
  83.         If TypeOf Ent Is AcadRegion Then
  84.             Set oReg = Ent
  85.             If N1(oReg) Then
  86.                 Ent.GetBoundingBox Min, Max
  87.                 If Rd(Min(2), Max(2)) Then
  88.                     Max = Min
  89.                     Max(2) = 0
  90.                     Ent.Move Min, Max
  91.                 End If
  92.             End If
  93.         End If
  94.         If TypeOf Ent Is AcadPoint Then
  95.             Set oPoint = Ent
  96.             oPoint.Coordinates = Z0(oPoint.Coordinates)
  97.         End If
  98.         If TypeOf Ent Is AcadBlockReference Then
  99.             Set oBref = Ent
  100.             If N1(oBref) Then
  101.                 oBref.InsertionPoint = Z0(oBref.InsertionPoint)
  102.                 If oBref.HasAttributes Then
  103.                     Atts = oBref.GetAttributes
  104.                     For Each Att In Atts
  105.                         Att.InsertionPoint = Z0(Att.InsertionPoint)
  106.                         'Att.TextAlignmentPoint = Z0(Att.TextAlignmentPoint)
  107.                     Next
  108.                 End If
  109.             End If
  110.         End If
  111.         If TypeOf Ent Is AcadMText Or TypeOf Ent Is AcadText Then
  112.             If N1(Ent) Then
  113.                 Ent.InsertionPoint = Z0(Ent.InsertionPoint)
  114.             End If
  115.         End If
  116.         If TypeOf Ent Is AcadLeader Then
  117.             Set oLeader = Ent
  118.             P1 = oLeader.Normal
  119.             If N1(oLeader) Then
  120.                 El(2) = oLeader.Coordinate(0)(2)
  121.                 oLeader.Move El, Zero
  122.             End If
  123.         End If
  124.         If TypeOf Ent Is AcadDimension Then
  125.      
  126.         
  127.         End If
  128.     Next
  129. End Sub
  130. Function Z0(P1 As Variant) As Variant
  131.     P1(2) = 0
  132.     Z0 = P1
  133. End Function
  134. Function N1(Ent As AcadEntity) As Boolean
  135.     Dim n As Variant, Norm(2) As Double
  136.     Norm(2) = 1
  137.     n = Ent.Normal
  138.     If Rd(n(0), 0) Then
  139.         If Rd(n(1), 0) Then
  140.             If Rd(n(2), 1) Then
  141.                 N1 = True
  142.                 If TypeOf Ent Is AcadRegion Or _
  143.                        TypeOf Ent Is AcadLeader Then
  144.                     Else
  145.                     Ent.Normal = Norm
  146.                 End If
  147.             ElseIf Rd(n(2), -1) Then
  148.                 If TypeOf Ent Is AcadCircle Then
  149.                     Ent.Normal = Norm
  150.                     N1 = True
  151.                 End If
  152.             End If
  153.         End If
  154.     End If
  155. End Function
  156. Function MoveByBB(Ent As AcadEntity)
  157.     Dim Min, Max
  158.     Ent.GetBoundingBox Min, Max
  159.     If Rd(Min(2), Max(2)) Then
  160.         Max = Min
  161.         Max(2) = 0
  162.         Ent.Move Min, Max
  163.     End If
  164. End Function
  165. Function Rd(num1 As Variant, num2 As Variant) As Boolean
  166.     Dim dRet As Double
  167.     dRet = num1 - num2
  168.     If Abs(dRet) < 0.00000001 Then Rd = True
  169. End Function

回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2006-6-4 14:50:01 | 显示全部楼层
这是暗淡变平的开始。
  1. Sub DimPointsToZero()
  2.     Dim StartPoint As Variant
  3.     Dim EndPoint As Variant
  4.     Dim DimLinePoint As Variant
  5.     Dim DimBlock As AcadBlock
  6.     Dim sName As String
  7.     Dim Ent As AcadEntity
  8.     Dim oPoint As AcadPoint
  9.     Dim oDim As AcadDimension
  10.     Dim i As Integer, j As Integer
  11.     Set oDim = EntSel
  12.     sName = vbAssoc(oDim, 2)
  13.     Set DimBlock = ThisDrawing.Blocks(sName)
  14.     For i = 0 To DimBlock.Count - 1
  15.         Set Ent = DimBlock(i)
  16.         If TypeOf Ent Is AcadPoint Then
  17.             Set oPoint = Ent
  18.             Select Case j
  19.                 Case 0
  20.                     StartPoint = oPoint.Coordinates
  21.                     StartPoint(2) = 0
  22.                     oPoint.Coordinates = StartPoint
  23.                 Case 1
  24.                     EndPoint = oPoint.Coordinates
  25.                     EndPoint(2) = 0
  26.                     oPoint.Coordinates = EndPoint
  27.                 Case 2
  28.                     DimLinePoint = oPoint.Coordinates
  29.                     DimLinePoint(2) = 0
  30.                      oPoint.Coordinates = DimLinePoint
  31.             End Select
  32.             j = j + 1
  33.             oPoint.Update
  34.         End If
  35.     Next i
  36. Debug.Print oDim.Rotation
  37. Debug.Print vbAssoc(oDim, 50)
  38. Dim newDim As AcadDimension
  39. Dim Cs As AcadBlock
  40. Set Cs = CurrentSpace
  41. Dim xT, xV
  42. oDim.GetXData "", xT, xV
  43. Set newDim = Cs.AddDimRotated(StartPoint, EndPoint, DimLinePoint, vbAssoc(oDim, 50))
  44. newDim.Layer = oDim.Layer
  45. newDim.TrueColor = oDim.TrueColor
  46. If Not IsEmpty(xV) Then
  47.     newDim.SetXData xT, xV
  48. End If
  49. newDim.StyleName = oDim.StyleName
  50. oDim.Delete
  51. End Sub

到目前为止,它看起来不错,但没有联想。
块的这种用法是由Randall开始的,但是没有人能找出块句柄。所以我咬断了,加上一些口齿不清的话。也许如果Dxf 10,13,14,15代码是可读写的,它们可以这样调整(我不知道如何设置)
也许有一种方法可以设置扩展字典
回复

使用道具 举报

71

主题

928

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1230
发表于 2006-6-4 21:27:14 | 显示全部楼层
我刚从我孙女的第二次BD派对回来,所以我现在要看看......
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-5 18:56 , Processed in 0.641201 second(s), 72 queries .

© 2020-2025 乐筑天下

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