乐筑天下

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

多段线是否仅适用于阵列?

[复制链接]

86

主题

744

帖子

6

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1092
发表于 2008-10-7 14:27:01 | 显示全部楼层 |阅读模式
所以我'我对编程思想不熟悉。本人'我用LISP做了一些项目,并自定义了我的托盘命令。但是现在我想花一些时间来理解如何做Autocad能够做的更详细的事情。所以我从一个简单的任务开始…,我想在图形中选择一个点
弹出一个表单,给我三个选项
上升、运行和立管数量
然后点击;“魔术”
命令按钮
然后Poof,它将创建一条多段线,看起来像楼梯
我想这将是一个简单的项目,让我开始,它有所有伟大的元素。我读了很多不同的教程,看到了许多不同的例子,也学到了很多其他项目是如何工作的。所以现在我'我卡住了。我知道在哪里申报。我知道如何添加模块。我知道如何创建表单,以及如何将表单的结果显示在模块中。如果一切都公开了,为什么这些价值观没有从一个模块传递到另一个模块
Dim absairs为双精度&nbsp 所有声明均在本图纸的页面顶部作出,Dim Bbstairs As Double
Dim Cbstairs As Double>Dim R As Integer
Dim X As Double
Dim Y As doublep
Dim ptstair As Variant
Dim p As Collection
Dim i As Integer
Public Sub stair()ptstair=thisdrawing.Utility。GetPoint(,“选择点”)
MsgBox ptstair(0)&amp&引用&引用&ptstair(1)&amp&引用&引用&ptstair(2)
absairs=ptstair(0)[b]Cbstairs=ptstair(2)
R=StrOpt。textboxR=StrOpt。textboxXY=StrOpt。text方形;在使用之前,你必须先对一个集合执行此操作
 设置p=新集合;我们需要r*2+1分,因为我们先上去;这给了我们r条水平线 对于i=1到R*2+1&nbsp 这行告诉我们它是否#039;s奇数或偶数;i Mod 2=0意味着i是偶数&nbsp (i除以2得到0的余数)&nbsp&nbsp 如果i Mod 2=0,则&nbsp&nbsp&nbsp&nbsp p、 添加;(“Abstrairs+X*(i-2)/2&amp&quot&引用&Bbstairs+Y*i/2&amp&quot&引用&Cbstairs&amp")&引用
&nbsp&nbsp 其他&nbsp&nbsp&nbsp&nbsp p、 添加;(“Abstrairs+X*(i-1)/2&amp&quot&引用&Bbstairs+Y*(i-1)/2&amp&quot&引用&Cbstairs&amp")&引用
&nbsp&nbsp 结束If&039;这只是将变量输出到电子表格,以便您可以检查它;你可能
&039 韩元#039;无法在AutoCAD中执行此操作;这是循环的结束;它告诉我增加1 下一个iMsgBox p(1)&p(2)&nbsp 此消息框显示p的值,但它不参考先前选择的点
我尝试了不同的语法,让addpolyline从集合中查找p的值,并将其用于应包含在多段线中的点。我在想,在这个庄园中,只有数组可以用于多段线。但不确定
如果有更好的方法,请结束Sub;我愿意接受新的方向。这是对我来说最有意义的一个。我遇到了这么多的路障,很明显我有这么多的家庭作业要做。也许有一天,我会变得足够熟悉,转而使用acad.net。那太好了
谢谢大家。
回复

使用道具 举报

86

主题

744

帖子

6

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1092
发表于 2008-10-7 14:55:10 | 显示全部楼层
首先……欢迎来到沼泽。其次……它对我很有用&nbsp
我唯一要更改的是将DIM设置为PUBLIC,因为您希望将这些变量提供给其他模块
现有代码…
  1. Dim Abstairs As Double
  2. Dim Bbstairs As Double
  3. Dim Cbstairs As Double
  4. Dim R As Integer
  5. Dim X As Double
  6. Dim Y As Double
  7. Dim ptstair As Variant
  8. Dim p As Collection
  9. Dim i As Integer

更改的代码…
  1. Public Abstairs As Double
  2. Public Bbstairs As Double
  3. Public Cbstairs As Double
  4. Public R As Integer
  5. Public X As Double
  6. Public Y As Double
  7. Public ptstair As Variant
  8. Public p As Collection
  9. Public i As Integer
哦,我总是使用Option Explicit,这意味着所有变量都必须声明。
回复

使用道具 举报

4

主题

54

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2008-10-7 16:10:05 | 显示全部楼层
我喜欢做的一件事是把我的公共变量移到一个代码模块(这个绘图在技术上是一个类模块)顺便说一句,这是一个'新家伙&#039。。。。。欢迎
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2008-10-7 16:12:49 | 显示全部楼层

这里也一样……想想吧……我可以'我不记得上一次我在这个绘图中有任何代码(除了一个早已消亡的旧ACAD.dvb文件)。
回复

使用道具 举报

4

主题

54

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2008-10-7 17:42:49 | 显示全部楼层

我认为你是对的 AddPolyline方法需要一个数组&nbsp VBA帮助还不错,应该有示例 数组需要声明为双精度(实数) 看起来您的集合是字符串的集合(其中包含数字的文本字符串看起来非常模糊)&nbsp 你'我有一个很好的开始,大部分工作都做得很好&nbsp
回复

使用道具 举报

4

主题

54

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2008-10-8 10:20:49 | 显示全部楼层
谢谢大家的好意;我会让你了解最终代码的最新信息。
回复

使用道具 举报

170

主题

1424

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
2119
发表于 2008-10-8 16:06:34 | 显示全部楼层
到目前为止进展顺利。可以直到现在。谁能指出我的逻辑哪里错了,或者我的语法哪里坏了
  1. Option Explicit
  2. Dim pt As Variant
  3. Public Ab0 As Double
  4. Public Bb0 As Double
  5. Public Cb0 As Double
  6. Public abc As Double
  7. Public R As Integer
  8. Public X As Double
  9. Public Y As Double
  10. Dim ptstair As Variant
  11. Dim p As Variant
  12. Dim i As Integer
  13. Dim RR
  14. Dim PLP(0 To 2) As Double
  15. Dim plpoints
  16. Dim plp00 As Double
  17. Dim plp01 As Double
  18. Dim plp02 As Double
  19. Public Sub SelPoint()
  20.       pt = ThisDrawing.Utility.GetPoint(, "Select Point:")
  21. MsgBox pt(0) & ";" & pt(1) & ";" & pt(2)
  22.              Ab0 = pt(0)
  23.              Bb0 = pt(1)
  24.              Cb0 = pt(2)
  25. StrOpt.Show                 'this calls the form StrOpt. Where I input the values for the rise, run, and number of risers.
  26. End Sub
  27. Public Sub makestair()
  28. R = StrOpt.textboxR        'This is the number of risers
  29. X = StrOpt.textboxX        'This is the Run of the riser
  30. Y = StrOpt.textboxY        'This is the Rise of the riser
  31. RR = (R * 2) + 1              ' This is the number of times the step needs to repeat. 4 Risers will require
  32.                                     '9 points in the polyline
  33.                                         ' You always have to do this with a collection before you can use it.
  34.     Set p = New Collection
  35.    
  36.                                           ' i is equal to integers 1 thru RR,(number of points needed for polyline)
  37.     For i = 1 To RR Step 1
  38.         If i Mod 2 = 0 Then         'if i divided by 2 has a remainder of 0, an even number, then I would
  39.                                            'like for the following formula.
  40.             plp00 = Ab0 + X * ((i - 2) / 2)
  41.             plp01 = Bb0 + Y * (i / 2)
  42.             plp02 = Cb0
  43.             MsgBox plp00 & plp01 & plp02
  44.             
  45.             PLP(0) = plp00: PLP(1) = plp01: PLP(2) = plp02     ' here is where I would like to take the three values and
  46.                                                                                 'and turn them back into a variant that will be used in the
  47.                                                                                 ' add polyline command.
  48.             p.Add (PLP())
  49.             
  50.         Else                    'if i divided by 2 has  a remainder not equal to 0, odd number, then I
  51.                                 'would like the following formula.
  52.             plp00 = Ab0 + X * ((i - 1) / 2)
  53.             plp01 = Bb0 + Y * ((i - 1) / 2)
  54.             plp02 = Cb0
  55.             MsgBox plp00 & plp01 & plp02
  56.             
  57.             PLP(0) = plp00: PLP(1) = plp01: PLP(2) = plp02
  58.             p.Add (PLP())
  59.         End If
  60.     Next i
  61.                                         ' now I should have a collection of items that are variants.  
  62. plpoints = p.Item(PLP(4))            
  63. MsgBox plpoints
  64. End Sub
我知道我可以得到一个点并提取这三个变体。我该怎么做呢。使用三个数字并使其成为单个变量的变体
谢谢大家
回复

使用道具 举报

86

主题

744

帖子

6

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1092
发表于 2008-10-8 17:29:11 | 显示全部楼层
我不知道'我在这里没有太多时间,但你知道在运行时有多少分
Dim pts()
Dim totalpts as integer
totalpts=x
redim pts(totalpts-1)
现在在您的循环中
pts(i*3)=:pts(i*3+1)=etc我只使用lwpline,因此数学与重样条不同
回复

使用道具 举报

4

主题

54

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
70
发表于 2008-10-8 18:08:47 | 显示全部楼层
布莱科's的建议看起来不错 我会去掉这个集合,只使用点的redim数组 It#039;因为AddPolyline方法没有#039;t实际上使用点——它使用一个包含xyzxyzxyzxyz值的数组 对于重多段线,PT应为双精度
其中RR是多段线中的顶点数-1是因为出于某种荒谬的原因,VB开始从0开始计数;数组最终应包含(对于9个顶点)
pts(0)=x1pts(5)=z2。
pts(24)=x9=25)=y9<pts(26)=z9因此在循环中i=1到RR(笑声),当你有PLP(0)=plp00:PLP(1)=PLP0.1:PLP.2)=PLP.02时,你可以改变(或添加)点((i-1)*3)=plp00:点((i-1)*3+1)=PLP0.01:点((i-1))*3+2)=PLp0.02,因为你的z总是一样的,你可以考虑使用轻量级多段线——它们使用更少的空间
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-7-4 02:21 , Processed in 1.892706 second(s), 70 queries .

© 2020-2025 乐筑天下

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