明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1092|回复: 5

[求助]急!急!急!关于块的问题

[复制链接]
发表于 2007-11-10 11:08:00 | 显示全部楼层 |阅读模式
<pre class="Code">首先我创建了一个块,随后在这个语句的后面有未知个语句(都是在CAD中画图元),</pre><pre class="Code">我想把这些语句所画的图元加入到前面建立的图块中,最后再把这个图块放到模型</pre><pre class="Code">的适当位置,但这些图元不知怎么才能加入到我所建立的图块当中?请各位大侠给点</pre><pre class="Code">提示!另外在程序中这样的环节还不少。</pre>
 楼主| 发表于 2007-11-10 11:15:00 | 显示全部楼层
补充一下,为了图形的美观,我为每一个图元都设置了不同的线型与颜色,图层也都分开了。
发表于 2007-11-10 16:00:00 | 显示全部楼层
<pre class="Code">Sub Example_InsertBlock()
    ' This example creates a block containing a circle.
    ' It then inserts the block.

    ' Create the block
    Dim blockObj As AcadBlock
    Dim insertionPnt(0 To 2) As Double
    insertionPnt(0) = 0#: insertionPnt(1) = 0#: insertionPnt(2) = 0#
    Set blockObj = ThisDrawing.Blocks.Add(insertionPnt, "CircleBlock")
   
    ' Add a circle to the block
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 0: center(1) = 0: center(2) = 0
    radius = 1
    Set circleObj = blockObj.AddCircle(center, radius)
   
    ' Insert the block
    Dim blockRefObj As AcadBlockReference
    insertionPnt(0) = 2#: insertionPnt(1) = 2#: insertionPnt(2) = 0
    Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock(insertionPnt, "CircleBlock", 1#, 1#, 1#, 0)
   
    ZoomAll
   
End Sub</pre>
 楼主| 发表于 2007-11-12 08:54:00 | 显示全部楼层
是这样的。
'=====================================================================================================
Call Example_InsertBlock(a)'a 是不定字符变量,根据要求建立不同的块名。
for i=1 to n'n值会在程序的其它地方给定此处未知
   Call Example_Addline(x1,y1,x2,y2)'有关参数值的程序已被略掉
   Call Example_AddCircle(x,y,r)
 
Next i
'==============我是想把以上部分画的图元加入到未知变量“a”的块中========================================   
Sub Example_AddLine(x1 as double,y1 as double,x2 as double,y2 as double)
       
    Dim lineObj As AcadLine
    Dim startPoint(0 To 2) As Double
    Dim endPoint(0 To 2) As Double
    
    startPoint(0) = x1: startPoint(1) = y1: startPoint(2) = 0#
    endPoint(0) = x2: endPoint(1) = y2: endPoint(2) = 0#
    
        Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
    ZoomAll
    
End Sub
Sub Example_AddCircle(x1 as double,y1 as double,r as double)
     
    Dim circleObj As AcadCircle
    Dim centerPoint(0 To 2) As Double
    Dim radius As Double
    
    
    centerPoint(0) = x1: centerPoint(1) = y1: centerPoint(2) = 0#
    radius = r
    
     Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)
   
    
End Sub
		

 楼主| 发表于 2007-11-12 09:25:00 | 显示全部楼层

Call Example_InsertBlock(a)这个是建立块的子程序。

另外在这个语句下面有多少个画图元的语句也都是不一样。

 楼主| 发表于 2007-11-12 12:25:00 | 显示全部楼层

问题解决了,谢谢大侠费心。

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

本版积分规则

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

GMT+8, 2024-11-26 12:34 , Processed in 0.179876 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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