找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 423|回复: 1

[编程申请]:如何生成一个既有弧又有线的复杂多边形?使用vba

[复制链接]
发表于 2004-5-17 16:38:47 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我想使用vba生成一个既有弧又有线的复杂多边形,但是现在的工作中,出现了,线是线,但弧也是线的情况,即,弧的起点和终点变成了线的起点和终点。不知道是什么原因,请高手赐教

sub makeshap()
    dim points(5) as point3d
    dim centerpoint as point3d
    dim ostringelements(5) as chainableelement
    dim ocomplexshape as complexshapeelement
    dim onewelement as element
   
    with points(0)
        .x = -100
        .y = 100
    end with
    with points(1)
        .x = 0
        .y = 100
    end with
    with points(2)
        .x = 100
        .y = 0
    end with
    with points(3)
        .x = 100
        .y = 0
    end with
    with points(4)
        .x = 100
        .y = -100
    end with
    with points(5)
        .x = -100
        .y = -100
    end with
    centerpoint.x = 0
    centerpoint.y = 0
        set onewelement = createlineelement2(nothing, points(0), points(1))
        set ostringelements(0) = onewelement
        
        set onewelement = createlineelement2(nothing, points(1), points(2))
        set ostringelements(1) = onewelement
        
        set onewelement = createarcelement1(nothing, points(3), centerpoint, points(2))
        set ostringelements(2) = onewelement
        activemodelreference.addelement onewelement
        onewelement.redraw
        
        set onewelement = createlineelement2(nothing, points(3), points(4))
        set ostringelements(3) = onewelement
        
        set onewelement = createlineelement2(nothing, points(4), points(5))
        set ostringelements(4) = onewelement
        
        set onewelement = createlineelement2(nothing, points(5), points(0))
        set ostringelements(5) = onewelement
    set ocomplexshape = createcomplexshapeelement1(ostringelements, msdfillmodenotfilled)
    activemodelreference.addelement ocomplexshape
    ocomplexshape.redraw
end sub
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2004-5-18 08:02:53 | 显示全部楼层
你的point(2)和point(3)两点的坐标均为(100,0),等于是建立了一个为点的弧!

-----------------------------------------------------------------------------
另外,我觉得您的程序可简化为如下:

Sub makeshap()
Dim points(5) As Point3d
Dim centerpoint As Point3d
Dim ostringelements(5) As ChainableElement
Dim ocomplexshape As ComplexShapeElement

points(0) = Point3dFromXY(-100, 100)
points(1) = Point3dFromXY(0, 100)
points(2) = Point3dFromXY(100, 0)
points(3) = Point3dFromXY(100, 0)
points(4) = Point3dFromXY(100, -100)
points(5) = Point3dFromXY(-100, -100)
centerpoint = Point3dFromXY(0, 0)
Set ostringelements(0) = CreateLineElement2(Nothing, points(0), points(1))
Set ostringelements(1) = CreateLineElement2(Nothing, points(1), points(2))
Set ostringelements(2) = CreateArcElement1(Nothing, points(3), centerpoint, points(2))
Set ostringelements(3) = CreateLineElement2(Nothing, points(3), points(4))
Set ostringelements(4) = CreateLineElement2(Nothing, points(4), points(5))
Set ostringelements(5) = CreateLineElement2(Nothing, points(5), points(0))
Set ocomplexshape = CreateComplexShapeElement1(ostringelements, msdFillModeNotFilled)
ActiveModelReference.AddElement ocomplexshape
ocomplexshape.Redraw
End Sub
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-12-27 14:46 , Processed in 0.394472 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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