我想看一级黄色大片_久久亚洲国产精品一区二区_久久精品免视看国产明星_91久久青青青国产免费

您的位置:網(wǎng)站首頁 > CAD新聞

AutoVBA利用Hacth對象填充圖元對象

時(shí)間:2012-01-29 08:30:35 來源:未知

通過Hacth對象可以對圖元進(jìn)行填充,可以使用CBD自帶的圖案,或者使用外部圖庫中的圖案或者自定義臨時(shí)填充。創(chuàng)建Hatch對象并將其添加到ModelSpace集合,該函數(shù)需三個(gè)參數(shù)。以下代碼繪制一個(gè)Circle對象并創(chuàng)建填充。

Sub drawfilledcircle()
    Dim hatchobject As AcadHatch
    Dim outercircle(0) As AcadCircle
    Dim center As Variant
    Dim radius As Double
    With ThisDrawing.Utility
        center = .GetPoint(, "Click the position for the center.")
        radius = .GetDistance(center, "Enter the radius.")
    End With
    Set outercircle(0) = ThisDrawing.ModelSpace.AddCircle(center, radius)
    outercircle(0).color = acYellow
    outercircle(0).Update
    Set hatchobject = ThisDrawing.ModelSpace.AddHatch(acHatchPatternTypePreDefined, "SOLID", True)
    hatchobject.AppendInnerLoop (outercircle)
    hatchobject.Evaluate
    hatchobject.Update
End Sub

代碼完。

第一行聲明繪制填充圓的函數(shù),定義AcadCircle和AcadHatch對象,繪制圓形對其進(jìn)行填充。

AddHatch對象需要三個(gè)參數(shù),第一個(gè)是PatternType常數(shù)參數(shù),具有三個(gè)值:acHatchPatternTypePredefined,acHatchPatternTypeUserDefined,acHatchPatternTypeCustomfined,第二個(gè)參數(shù)指定填充圖元名稱,第三個(gè)參數(shù)指定填充是否關(guān)聯(lián)到邊界圖元,如果為false,填充不與邊界圖元相關(guān),若為true則填充隨圖元同時(shí)變化。


相關(guān)文章