明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1440|回复: 4

[VBA]

[复制链接]
发表于 2005-6-8 23:49:00 | 显示全部楼层 |阅读模式
Sub lengthenline()
Dim lineobj As AcadLine
Dim p1(0 To 2) As Double
Dim p2(0 To 2) As Double
p1(0) = 50: p1(1) = 50: p1(2) = 0
p2(0) = 60: p2(1) = 60: p2(2) = 0
setlineobj1 = ThisDrawing.ModelSpace.AddLine(p1, p2)
lineobj1.Update
Dim p3(0 To 2) As Double
Dim p4(0 To 2) As Double
p3(0) = 40: p3(1) = 80: p3(2) = 0
p4(0) = 100: p4(1) = 80: p4(2) = 0
Set lineobj2 = ThisDrawing.ModelSpace.AddLine(p3, p4)
lineobj1.EndPoint = lineobj2
lineobj1.Update
End Sub
发表于 2005-6-9 08:50:00 | 显示全部楼层
第一、变量定义问题dim lineobj1,lineobj2 as acadline 第二、setlineobj1 = ThisDrawing.ModelSpace.AddLine(p1, p2)
set和lineobj1中间加空格---------- 第三,lineobj1.EndPoint = lineobj2???这句什么意思?线一的末端点等于线一???lineobj1.EndPoint = lineobj2.startpoint
发表于 2005-6-9 09:42:00 | 显示全部楼层
dim lineobj1,lineobj2 as acadline的定义声明了一个Variant型变量lineobj1         一个acadline型的变量lineobj2这不是楼上的同学想要的吧?VB的变量声明要写全了dim lineobj1 as acadline,lineobj2 as acadline
 楼主| 发表于 2005-6-9 19:37:00 | 显示全部楼层

[VBA]

Sub lengthenline()
Dim lineobj1 As AcadLine,lineobj2 As AcadLine
Dim p1(0 To 2) As Double
Dim p2(0 To 2) As Double
p1(0) = 50: p1(1) = 50: p1(2) = 0
p2(0) = 60: p2(1) = 60: p2(2) = 0
set lineobj1 = ThisDrawing.ModelSpace.AddLine(p1, p2)
lineobj1.Update
Dim p3(0 To 2) As Double
Dim p4(0 To 2) As Double
p3(0) = 40: p3(1) = 80: p3(2) = 0
p4(0) = 100: p4(1) = 80: p4(2) = 0
Set lineobj2 = ThisDrawing.ModelSpace.AddLine(p3, p4)
lineobj1.EndPoint = lineobj2.startpoint
lineobj1.Update
End Sub
我的意思是把第一条线段延伸到和第二条相交,而这个交点是未知的,并非是线二的起始点,帮忙想想办法,我们在搞毕业设计,真是没办法
发表于 2005-6-9 20:27:00 | 显示全部楼层
用IntersectWith函数求交点
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-27 14:37 , Processed in 0.185014 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表