yuliang2477 发表于 2007-11-10 11:08:00

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

<pre class="Code">首先我创建了一个块,随后在这个语句的后面有未知个语句(都是在CAD中画图元),</pre><pre class="Code">我想把这些语句所画的图元加入到前面建立的图块中,最后再把这个图块放到模型</pre><pre class="Code">的适当位置,但这些图元不知怎么才能加入到我所建立的图块当中?请各位大侠给点</pre><pre class="Code">提示!另外在程序中这样的环节还不少。</pre>

yuliang2477 发表于 2007-11-10 11:15:00

补充一下,为了图形的美观,我为每一个图元都设置了不同的线型与颜色,图层也都分开了。

toosimple 发表于 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>

yuliang2477 发表于 2007-11-12 08:54:00

<pre class="Code">是这样的。</pre><pre class="Code">'=====================================================================================================</pre><pre class="Code">Call Example_InsertBlock(a)'a 是不定字符变量,根据要求建立不同的块名。</pre><pre class="Code">for i=1 to n'n值会在程序的其它地方给定此处未知</pre><pre class="Code">   Call Example_Addline(x1,y1,x2,y2)'有关参数值的程序已被略掉</pre><pre class="Code">   Call Example_AddCircle(x,y,r)
</pre><pre class="Code">Next i</pre><pre class="Code">'==============我是想把以上部分画的图元加入到未知变量“a”的块中========================================   </pre><pre class="Code">Sub Example_<font color="#ffffff" style="BACKGROUND-COLOR: #316ac5;">AddLine</font>(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.<font color="#ffffff" style="BACKGROUND-COLOR: #316ac5;">AddLine</font>(startPoint, endPoint)
    ZoomAll
   
End Sub</pre><pre class="Code"><pre class="Code">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</pre></pre><pre class="Code">
                <br/>
                <br/></pre>

yuliang2477 发表于 2007-11-12 09:25:00

<p>Call Example_InsertBlock(a)这个是建立块的子程序。</p><p>另外在这个语句下面有多少个画图元的语句也都是不一样。</p>

yuliang2477 发表于 2007-11-12 12:25:00

<p>问题解决了,谢谢大侠费心。</p>
页: [1]
查看完整版本: [求助]急!急!急!关于块的问题