- 积分
- 3099
- 明经币
- 个
- 注册时间
- 2005-8-12
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
因为.NET在CAD2006下实现不了的一些功能后,我利用COM来建立属性块,这个虽然实现了,但到添加扩展数据时,
出现了致命错误,是否是我的代码有问题。不添加扩展数据时,还是很好用的。哪位大侠帮我看看,谢了!- <CommandMethod("GCD")> Public Sub GCD()
- Try
- acApp = DirectCast(Marshal.GetActiveObject(progID), AcadApplication)
- Catch
- Try
- Dim acType As Type = Type.GetTypeFromProgID(progID)
- acApp = DirectCast(Activator.CreateInstance(acType, True), AcadApplication)
- Catch
- Application.ShowAlertDialog("Cannot Create The ProgID")
- End Try
- End Try
- If acApp IsNot Nothing Then
- acApp.Visible = True
- Dim aDocument As AcadDocument = acApp.ActiveDocument
- Dim objBlkDef As Common.AcadBlock
- For Each objBlkDef In aDocument.Blocks
- If objBlkDef.Name = "GC200" Then
- Dim pt1 As Double() = New Double(2) {1, -1, 0}
- objBlkDef.AddAttribute(2, Common.AcAttributeMode.acAttributeModeNormal, "", pt1, "height", "20.35")
- For i As Integer = 0 To 10
- Dim pt As Double() = New Double(2) {500 + i * 10, 600 + i * 10, 0}
- Dim block As Common.AcadBlockReference = aDocument.ModelSpace.InsertBlock(pt, "GC200", 1, 1, 1, 0, )
- aDocument.Application.ZoomAll()
- Dim v As Object
- v = block.GetAttributes
- v(0).textstring = (100 + i * 10).ToString
- v(0).Alignment = Common.AcAlignment.acAlignmentMiddleLeft
- v(0).TextAlignmentPoint = pt
- v(0).update()
- Dim DataType(2) As Object
- Dim Data(2) As Object
- DataType(0) = 1001
- Data(0) = "SOUTH"
- DataType(1) = 1000
- Data(1) = "202101"
- block.SetXData(DataType, Data)
- Next
- End If
- Next
- End If
- End Sub
在block.SetXData(DataType, Data)上,出现致命错误的,因为VBA不懂,所以没有办法修改了!
|
|