明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2484|回复: 0

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

[复制链接]
发表于 2011-12-26 22:53:28 | 显示全部楼层 |阅读模式
--------------以下代码是在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 buffblock  As 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#创建带属性块的方法?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 18:52 , Processed in 0.151499 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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