乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 119|回复: 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东西,而只是
redim保留pnt1(0到1)
hatchobj.origin = pnt1
hatchobj.patternangle = hatchobj.patternangle + ((PI * 180)/180)
这难道不会给你带来想要的结果吗?
回复

使用道具 举报

6

主题

103

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
127
发表于 2008-5-6 14:58:02 | 显示全部楼层
目的是模仿孵化编辑,出于某种原因,属性变化的顺序使世界上的一切变得不同......我不需要物体专门旋转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 | 显示全部楼层
如果您想完全技术化,则在平面中为90,在平面中为-90。尝试一下。如果它是world 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

~'J'~
回复

使用道具 举报

6

主题

103

帖子

2

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
127
发表于 2008-5-6 16:28:38 | 显示全部楼层
谢谢你到目前为止的帮助...我已经设法解决了UCS问题。我仍然讨厌我们不能设置为“世界”而不必创建一个命名的UCS。
让我给你一点关于我在做什么的见解...它可能对你更有意义...
我们使用舱口来表示各种填充模式,从前我们使用各种比例的“线”来表示船板壁板,以及板条壁板,更不用说AR-CONC、AR-B816C等...大约2年前,我分解并定义了我们所有最常见的填充和一些不太常见的填充的自定义舱口模式,以使我们的生活更轻松,更不用说向BOM移动也使这也更容易...区分8"圈和6"圈的最简单方法是在放置舱口时定义比例,然后为BOM检索舱口的比例和大小...但是这导致人们做数学不正确(有些人喊出8"有些人喊出7 1/2"等...)我们现在已经预定义了孵化,这个名字是我们现在所需要的...
无论如何,各种舱口(根据标准)将被放置在它们相关联的各个层上。我们得到了不正确的比例、颜色、层,舱口原点会关闭,使舱口看起来不正确。所以,进入反应堆...
反应堆将抓取舱口项目及其名称,在舱口模式的左下方设置一个UCS,根据预定义的标准设置层、颜色、比例和旋转(我们的石头模式是随机完成的),重新评估舱口,更新实体并最终将UCS恢复到以前的状态。
现在我还有一个任务......
我们有一个金属屋顶的舱口模式,它在方形屋顶上正确对齐,但很多时候我们有一个三角形部分。默认情况下,我使用的是边界框的左下角。当三角形部分在左边时,最好使用边界框的右上角。所以...我想我需要得到外环并找到任意2个点之间最长的垂直平面...
回复

使用道具 举报

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 | 显示全部楼层
我对它做得还不够,如果不玩它,就不能真正提供任何见解,而且我也不太可能想出任何你玩它不能得到的东西。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

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

© 2020-2025 乐筑天下

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