乐筑天下

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

图案填充和UCS原点

[复制链接]

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2008-5-6 10:49:14 | 显示全部楼层 |阅读模式
我试图基于图案填充的边界框操纵UCS原点,然后相应地更新图案填充,但我没有取得任何进展
也许我错过了什么,但这一点;“应该”;工作..
  1. Dim Pnt1 As Variant
  2. Dim Pnt2 As Variant
  3. Dim XAx(2) As Double
  4. Dim YAx(2) As Double
  5. 'Get the bounding box
  6. HatchObj.GetBoundingBox Pnt1, Pnt2
  7. 'Get the current UCS so we can reset it
  8. Set UCSOrg = ThisDrawing.ActiveUCS
  9. 'Set the direction vectors of the temp UCS
  10. XAx(0) = Pnt1(0): XAx(1) = 0#: XAx(2) = 0#
  11. YAx(0) = 0#: YAx(1) = Pnt1(1): YAx(2) = 0#
  12. 'Create a new UCS
  13. Set NewUCS = ThisDrawing.UserCoordinateSystems.Add(Pnt1, XAx, YAx, "temp")
  14. 'Set it active
  15. ThisDrawing.ActiveUCS = NewUCS
  16. 'Evaluate the hatch --- this should reset the hatch based upon the current UCS, but it doesn't
  17. HatchObj.Evaluate
  18. 'Update the object
  19. HatchObj.UpDate
  20. 'Reset the previous UCS
  21. ThisDrawing.ActiveUCS = UCSOrg
  22. 'Remove our temp UCS
  23. ThisDrawing.UserCoordinateSystems.Item("temp").Delete


回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2008-5-6 13:16:15 | 显示全部楼层
因此,看一下,您正在创建一个ucs,其原点位于边界框的ll点,与当前旋转180度 从这里可以看出,更新图案填充是更改UCS的唯一原因 如果是'在这种情况下,为什么不去掉所有UCS的东西,只需重新定义pnt1(0到1)。原点=pnt1。patternangle=hatchobj。图案角度+((PI*180)/180)
;这不是你想要的结果吗?
回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2008-5-6 14:58:02 | 显示全部楼层
其目的是模仿hatchedit,出于某种原因,财产变化的顺序决定了世界上的一切……我没有'不需要将对象旋转180度(实际上是90度…)。旋转是无关紧要的,因为我将其设置为随机旋转角度。但我已经更改了它,以便在UCS中不进行旋转,稍后应用旋转…
  1. 'Get the hatch
  2.     Set HatchObj = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.Count - 1)
  3. 'and the bounding box
  4.     HatchObj.GetBoundingBox Pnt1, Pnt2
  5. 'create new UCS
  6.     Set UCSOrg = ThisDrawing.ActiveUCS
  7. 'set the vectors
  8.     XAx(0) = Pnt1(0) + 12: XAx(1) = Pnt1(1): XAx(2) = 0#
  9.     YAx(0) = Pnt1(0): YAx(1) = Pnt1(1) + 12: YAx(2) = 0#
  10. 'set the new UCS
  11.     Set NewUCS = ThisDrawing.UserCoordinateSystems.Add(Pnt1, XAx, YAx, "temp")
  12.     ThisDrawing.ActiveUCS = NewUCS
  13. 'set a constant scale (we can change this to what is needed)
  14.     HatchObj.PatternScale = 48
  15. 'make the pattern angle
  16.     HatchObj.PatternAngle = Int((48 * Rnd) + 1)
  17. 'assign the changes
  18.     HatchObj.Evaluate
  19. 'update the object
  20.     HatchObj.UpDate
  21. 'reset the origin
  22.     ThisDrawing.ActiveUCS = UCSOrg
  23. 'delete the temp origin
  24.     ThisDrawing.UserCoordinateSystems.Item("temp").Delete
如果我现在只能找到重置的方法;“世界”;UCS,因为它不是命名UCS,并且只有当世界确实处于活动状态时,才可以通过ActiveUCS使用它。显然,VBA在没有发送键的情况下无法做到这一点。当通过事件反应器操作时,这是有害的…
回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2008-5-6 15:23:15 | 显示全部楼层
如果你想完全掌握技术,可以试一试 如果是世界ucs,可能需要加入一个布尔值,并相应地删除末尾的旋转
  1. 'Get the hatch
  2.     Set HatchObj = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.Count - 1)
  3. 'and the bounding box
  4.     HatchObj.GetBoundingBox Pnt1, Pnt2
  5. 'create new UCS
  6.    If ThisDrawing.GetVariable("WORLDUCS") = 1 Then
  7.     With ThisDrawing
  8.     Set UCSOrg = .UserCoordinateSystems.Add( _
  9.     .GetVariable("UCSORG"), _
  10.     .Utility.TranslateCoordinates(.GetVariable("UCSXDIR"), acUCS, acWorld, 0), _
  11.     .Utility.TranslateCoordinates(.GetVariable("UCSYDIR"), acUCS, acWorld, 0), _
  12.     "whirled")
  13.     End With
  14.     Else
  15.     Set UCSOrg = ThisDrawing.ActiveUCS
  16.     End If
  17. 'set the vectors
  18.     XAx(0) = Pnt1(0) + 12: XAx(1) = Pnt1(1): XAx(2) = 0#
  19.     YAx(0) = Pnt1(0): YAx(1) = Pnt1(1) + 12: YAx(2) = 0#
  20. 'set the new UCS
  21.     Set NewUCS = ThisDrawing.UserCoordinateSystems.Add(Pnt1, XAx, YAx, "temp")
  22.     ThisDrawing.ActiveUCS = NewUCS
  23. 'set a constant scale (we can change this to what is needed)
  24.     HatchObj.PatternScale = 48
  25. 'make the pattern angle
  26.     HatchObj.PatternAngle = Int((48 * Rnd) + 1)
  27. 'assign the changes
  28.     HatchObj.Evaluate
  29. 'update the object
  30.     HatchObj.UpDate
  31. 'reset the origin
  32.     ThisDrawing.ActiveUCS = UCSOrg
  33. 'delete the temp origin
  34.     ThisDrawing.UserCoordinateSystems.Item("temp").Delete
回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2008-5-6 15:30:45 | 显示全部楼层
这是我的2美分
  1. Sub test()
  2. Dim AUcs As AcadUCS
  3. Dim WorldUCS As AcadUCS
  4. Dim NewUCS As AcadUCS
  5. Dim orig(2) As Double
  6. Dim vx(2) As Double
  7. Dim vy(2) As Double
  8. Dim hatchObj As AcadHatch
  9. Dim Pnt1(2) As Double
  10. Dim Pnt2(2) As Double
  11. Set AUcs = ThisDrawing.ActiveUCS
  12. With AUcs
  13. vx(0) = .XVector(0): vx(1) = .XVector(1): vx(2) = .XVector(2)
  14. vy(0) = .YVector(0): vy(1) = .YVector(1): vy(2) = .YVector(2)
  15. orig(0) = .Origin(0): orig(1) = .Origin(1): orig(2) = .Origin(2)
  16. End With
  17. '' just to inform , perhaps extrafluous here
  18. If vx(0) = 1# And vx(1) = 0# And vx(2) = 0# And _
  19.    vy(0) = 0# And vy(1) = 1# And vy(2) = 0# And _
  20.    orig(0) = 0# And orig(1) = 0# And orig(2) = 0# Then
  21. Debug.Print "World UCS"
  22. Set WorldUCS = ThisDrawing.UserCoordinateSystems.Add(orig, vx, vy, "WorldUCS")
  23. Else
  24. orig(0) = 0#: orig(1) = 0#: orig(2) = 0#
  25. vx(0) = 1#: vx(1) = 0#: vx(2) = 0
  26. vy(0) = 0#: vy(1) = 1#: vy(2) = 0#
  27. Set WorldUCS = ThisDrawing.UserCoordinateSystems.Add(orig, vx, vy, "WorldUCS")
  28. End If
  29. ''Get the hatch
  30.     Set hatchObj = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.Count - 1)
  31. ''and the bounding box
  32.     hatchObj.GetBoundingBox Pnt1, Pnt2
  33. 'create new UCS
  34.     'Set UCSOrg = ThisDrawing.ActiveUCS 'you are already there
  35. 'set the vectors
  36.     vx(0) = Pnt1(0) + 12: vx(1) = Pnt1(1): vx(2) = 0#
  37.     vy(0) = Pnt1(0): vy(1) = Pnt1(1) + 12: vy(2) = 0#
  38. 'set the new UCS
  39.     Set NewUCS = ThisDrawing.UserCoordinateSystems.Add(Pnt1, vx, vy, "temp")
  40.     ThisDrawing.ActiveUCS = NewUCS
  41. 'set a constant scale (we can change this to what is needed)
  42.     hatchObj.PatternScale = 48
  43. 'make the pattern angle
  44.     hatchObj.PatternAngle = Int((48 * Rnd) + 1)
  45. 'assign the changes
  46.     hatchObj.Evaluate
  47. 'update the object
  48.     hatchObj.Update
  49. 'reset the origin
  50.     ThisDrawing.ActiveUCS = WorldUCS
  51. 'delete the temp origin
  52.     ThisDrawing.UserCoordinateSystems.Item("temp").Delete
  53. End Sub

~&039;J#039~
回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2008-5-6 16:28:38 | 显示全部楼层
谢谢你到目前为止的帮助…我已经设法克服了UCS的问题。我仍然痛恨我们不能设定为“;“世界”;无需创建命名UCS
让我给你一点关于我正在做的事情的见解。这可能对你更有意义…
我们使用hatch来填充各种填充图案,以前我们使用;“行”;以各种比例表示搭船专用线和board&板条壁板,更不用说AR-CONC、AR-B816C等……大约2年前,我分解并定义了所有最常见填充的自定义图案,以及一些不太常见的填充图案,以使我们的生活更轻松,更不用提向BOM移动也使其更容易……区分8”的最简单方法;搭接和6“;lap本来是在放置图案填充时定义比例,然后检索BOM的图案填充比例和大小。但这导致人们的数学计算不正确(有些人叫8,有些人叫7 1/2等等)。我们现在已经预定义了图案填充,名称就是我们现在需要的全部…
,各种图案填充(按标准)将放置在与其相关的各个层上。我们得到了不正确的比例、颜色、图层,图案填充原点将被关闭,使图案填充看起来不正确。因此,输入reactor…
reactor将抓取图案填充项及其名称,在图案填充的左下角设置UCS,根据预定义标准设置图层、颜色、比例和旋转(我们的石头图案是随机完成的),重新评估图案填充,更新实体,最后将UCS返回到以前的条件
现在我还有一个任务……我们有一个金属屋顶的剖面线图案,它在正方形屋顶上正确对齐,但很多时候我们有三角形截面。默认情况下,我使用边界框的左下角。当三角形部分位于左侧时,最好使用边界框的右上角。所以…我想我需要得到外环并找到任意两点之间最长的垂直面…<返回按键敲击>
回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2008-5-7 11:15:37 | 显示全部楼层
我的反应堆工作正常,除了偶尔在评估舱口的新属性时出错&引用;图案填充过密“;和“;输出不明确“;似乎是最大的,即使舱口比例没有改变。本人'我想更好地理解方法,以便解决这个问题。如有任何见解,将不胜感激。
回复

使用道具 举报

154

主题

1274

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1936
发表于 2008-5-8 13:13:52 | 显示全部楼层
哈文#039;如果不使用它,我做得还不够,无法真正提供任何见解,我可能也不太可能想出任何你做不到的东西't通过玩它。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-5 15:34 , Processed in 0.835106 second(s), 68 queries .

© 2020-2025 乐筑天下

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