spring 发表于 2004-5-27 19:46:00

[求助]求助这样的功能用 VBA 怎么实现

这样的功能用 VBA 怎么实现
(defun c:as (/ ss ss1 ss2)
       (command "_.LINE" "0,0" "0,10" "")        ;画第一条线
       (setq ss (ssget "l"))                        ;取得最后一个对象
       (command "_.LINE" "0,10" "10,10" "")        ;画第二条线
       (setq ss1 (ssget "l"))                ;取得最后一个对象
       (command "_.LINE" "10,10" "0,0" "")        ;画第三条线
       (setq ss2 (ssget "l"))                ;取得最后一个对象
       (command "_.PEDIT" ss "Y" "J" ss ss1 ss2 "" "") ;串接
)

雪山飞狐_lzh 发表于 2004-5-27 19:53:00

由顶点列表创建优化多段线。
参阅 | 示例
语法
RetVal = object.AddLightweightPolyline(VerticesList)
Object
ModelSpace 集合, PaperSpace 集合, Block
使用该方法的对象。
VerticesList
Variant[变体] (双精度数组)
指定多段线顶点的二维 OCS 坐标数组。至少需要两点(四个元素)以构成优化多段线。数组大小必须为2的倍数。
RetVal
LightweightPolyline 对象
新创建的 LightweightPolyline 对象。
说明
顶点是生成多段线的线段端点。要添加弧段,首先创建全部为直线段的多段线,然后为个别需要变为弧段的线段添加凸度。要为线段添加凸度值,可使用 SetBulge 方法。
多段线的标高将被设置为布局的当前标高。使用 ElevationModelspace 或 ElevationPaperspace 属性可确定多段线的标高。
坐标可使用 TranslateCoordinates 方法在OCS坐标与其它坐标系统相互转换。

spring 发表于 2004-5-27 21:05:00

可是我对 VBA 一点都不懂,我现在需要一个这样的 VBA 程序,可以帮忙写一个吗

雪山飞狐_lzh 发表于 2004-5-27 21:09:00

&ltRE class=Code>Sub Example_AddLightWeightPolyline()
    ' This example creates a lightweight polyline in model space.
   
    Dim plineObj As AcadLWPolyline
    Dim points(0 To 9) As Double
   
    ' Define the 2D polyline points
    points(0) = 1: points(1) = 1
    points(2) = 1: points(3) = 2
    points(4) = 2: points(5) = 2
    points(6) = 3: points(7) = 2
    points(8) = 4: points(9) = 4
      
    ' Create a lightweight Polyline object in model space
    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    ZoomAll
   
End Sub

spring 发表于 2004-5-27 21:46:00

谢谢!!!我看了一下,你的程序是用多义线画的吗?
我要用 pedit 串接起来的

雪山飞狐_lzh 发表于 2004-5-27 21:51:00

有什么区别么?

spring 发表于 2004-5-27 22:45:00

有区别
我的思路是这样的,每画好一根线将线的实体名保存在一个变量里。供以后的程序调用,除了 PEDIT 外还有起它的

雪山飞狐_lzh 发表于 2004-5-27 22:51:00

但是你的直线已经被串接了,还有保存的必要么?

spring 发表于 2004-5-27 23:02:00

我在串接之前可以用啊

雪山飞狐_lzh 发表于 2004-5-27 23:19:00

Sub Test()
                       Dim pnt(2) As Double, dot(2) As Double
                       Dim pobj(2) As AcadLine
                       Dim CmdStr As String
                       dot(1) = 10
                       Set pobj(0) = ThisDrawing.ModelSpace.AddLine(pnt, dot)
                       pnt(0) = 10: pnt(1) = 10
                       Set pobj(1) = ThisDrawing.ModelSpace.AddLine(dot, pnt)
                       dot(1) = 0
                       Set pobj(2) = ThisDrawing.ModelSpace.AddLine(pnt, dot)
                       CmdStr = _
                                                                                       "_.Pedit" & vbCr & _
                                                                                       "(handent " & Chr(34) & pobj(0).Handle & Chr(34) & ")" & vbCr & _
                                                                                       "Y" & vbCr & "J" & vbCr & _
                                                                                       "(handent " & Chr(34) & pobj(0).Handle & Chr(34) & ")" & vbCr & _
                                                                                       "(handent " & Chr(34) & pobj(1).Handle & Chr(34) & ")" & vbCr & _
                                                                                       "(handent " & Chr(34) & pobj(2).Handle & Chr(34) & ")" & vbCr & _
                                                                                       vbCr & vbCr
                                                                                       
                       ThisDrawing.SendCommand CmdStr
End Sub
页: [1]
查看完整版本: [求助]求助这样的功能用 VBA 怎么实现