雪域藏金 发表于 2011-12-26 22:53:28

求助:用AutoCAD.Net C#创建带属性块的方法?

--------------以下代码是在AUTOCAD2004中用VBA创建带属性的块

Private Sub MyDFZK1(Mblk As String)
    Dim circleObj(0) As AcadCircle
    Dim radius As Double
   
   Dim insPt(0 To 2) As Double
   
    insPt(0) = 0:    insPt(1) = 0:    insPt(2) = 0
    Dim buffblockAs AcadBlock
    Set buffblock = ThisDrawing.Blocks.Add(insPt, Mblk)
   
   
    radius = 1#
   
    Set circleObj(0) = buffblock.AddCircle(insPt, radius)
   
   
   
    Dim hatchObj As AcadHatch
    Dim patternName As String
    Dim PatternType As Long
    Dim bAssociativity As Boolean
   
    ' 定义和创建图案填充
    patternName = "SOLID"
    PatternType = 0
    bAssociativity = True
    Set hatchObj = buffblock.AddHatch(PatternType, patternName, bAssociativity)

    hatchObj.AppendOuterLoop (circleObj)
    hatchObj.Evaluate
   
    radius = 2#
   
    Set circleObj(0) = buffblock.AddCircle(insPt, radius)
   
    Dim attributeObj As AcadAttribute
    Dim height As Double
    Dim mode As Long
    Dim prompt As String
    Dim insertionPoint(0 To 2) As Double
    Dim tag As String
    Dim value As String
   
    height = 2.5
    mode = acAttributeModeNormal
    prompt = "孔号:"
    insertionPoint(0) = insPt(0) + 5#: insertionPoint(1) = insPt(1) + 5#: insertionPoint(2) = insPt(2)
    tag = "孔号"
    value = "ZK001"
   
    Set attributeObj = buffblock.AddAttribute(height, mode, prompt, insertionPoint, tag, value)
   
    ThisDrawing.Regen (True)
End Sub


请各位大侠指点,在AUTOCAD2007中,用AUTOCAD.NET   C#创建带属性块的方法?
页: [1]
查看完整版本: 求助:用AutoCAD.Net C#创建带属性块的方法?