tralles 发表于 2022-7-6 22:11:32

VBA偏移问题

你好
 
我有个问题。我想使多段线偏移,并想知道新多段线的坐标。
我编写代码,选择给定距离的多段线和偏移量,但不学习新的多段线坐标。
请帮忙。

Tyke 发表于 2022-7-6 22:35:24

在VBA代码中,为多段线声明一个变量,并将其设置为多段线。然后,该多段线对象具有一个偏移方法,该方法将创建一个新的多段线对象作为变量对象。然后,可以列出新多段线对象的坐标。

BIGAL 发表于 2022-7-6 23:06:00

这是pline的一个代码,我将代码更改为使用上次创建的实体。
 
(defun getcoords (ent)

(vlax-safearray->list

   (vlax-variant-value

   (vlax-get-property

   (vlax-ename->vla-object ent)

   "Coordinates"

   )

   )

)

)



(defun co-ords2xy (I numb xy)

; convert now to a list of xy as co-ords are x y x y x y if 3d x y z x y z

(setq numb (/ (length co-ords) 2))

(setq I 0)

(repeat numb

(setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))

(setq co-ordsxy (cons xy co-ordsxy))

(setq I (+ I 2))

)

)



; program starts here

;(setq co-ords (getcoords (car (entsel "\nplease pick pline"))))
(setq co-ords (getcoords (car (entlast))))
(co-ords2xy)

tralles 发表于 2022-7-6 23:19:42

谢谢大家,
我写代码供审查。第一条多段线坐标良好。但我不能学习新的折线。
我要在第一条多段线第一个顶点和第二条多段线最后一个顶点之间绘制第三条多段线
 
 
私有子命令按钮1\u Click()
Dim basePnt作为变型
Dim returnObj作为AcadObject
将距离变暗为双精度
Dim VERTEXTS作为变体
Dim numberofvertices等长
 
On Local Error GoTo err On Error Resume Next(本地错误转到错误时继续下一步)
UserForm1.hide
此图纸。公用事业GetEntity returnObj,basePnt,“选择多段线”
例如,距离=50’
returnObj。偏移(距离)
vertexPts=返回对象。协调
顶点数=UBound(vertexPts)+1
对于i=0到顶点数-1步骤2
MsgBox“&顶点表达式(i)&”、“&顶点表达式(i+1)
下一个i
UserForm1.show
出口接头
 
错误:
如果出错。数字=-2147352567,然后
UserForm1.show
如果结束
末端接头
页: [1]
查看完整版本: VBA偏移问题