Jeff_M 发表于 2010-6-24 15:11:40

因此,在C3D 2011(我今天早上刚刚安装,目前正在摸索它的陷阱)中,出现了更多问题。
现在,当我调用该命令时,我收到一条错误消息,显示第二行代码为:
Dim oApp As AeccApplication
一些Google告诉我有一个引用错误,但我不明白a)什么是引用,或者b)如何解决2011年的问题。
这是我当前使用的完整代码:
Sub test()
Dim oApp As AeccApplication
Dim oDoc As AeccDocument
Dim oSurfs As AeccSurfaces
Set oApp = Application.GetInterfaceObject("AeccXUiLand.AeccApplication.7.0")
Set oDoc = oApp.ActiveDocument
Set oSurfs = oDoc.Surfaces
Dim Tindata As New AeccTinCreationData
Tindata.Description = "Building Surface from CPP Building datum" 'SET SURFACE DESCRIPTION
Tindata.Layer = "Surface Bldgs"               'SET SURFACE LAYER
Tindata.BaseLayer = "Surface Bldgs"             'NOT SURE WHAT THIS DOES
Tindata.Style = "Building Surfaces"             'SET SURFACE STYLE
Dim osurf As AeccSurface
Dim iCount As Integer
For Each osurf In oSurfs
    If osurf.Name Like "BLDG ###" Then
      Dim iTmp As Integer
      iTmp = CInt(Right(osurf.Name, 3))
      If iTmp > iCount Then iCount = iTmp
    End If
Next
Dim sCurName As String
Dim oEnt1 As AcadEntity
Dim oEnt2 As AcadEntity
Dim vPick As Variant
Dim oEnts(0) As AcadEntity
Do Until Err.Number0
    iCount = iCount + 1
    sCurName = "BLDG " & Format(iCount, "000")
    On Error GoTo ResumeHere
    ThisDrawing.Utility.GetEntity oEnt1, vPick, vbCr & "Select inside pline: "
    Dim sOtype As String
    sOtype = UCase(oEnt1.ObjectName)
    If Not ((sOtype Like "*POLY*") Or (sOtype Like "*FEATURE*")) Then
      Err.Raise -4444444, , "Incorrect object type selected!"
      GoTo ResumeHere
    ''Remove the ElseIf section when the API allows Featurelines
    ElseIf sOtype Like "*FEATURE*" Then
      Err.Raise -4444445, , "Featurelines not currently supported, explode and try again!"
      GoTo ResumeHere
    End If
    ThisDrawing.Utility.GetEntity oEnt2, vPick, vbCr & "Select outside pline: "
    sOtype = UCase(oEnt2.ObjectName)
    If Not ((sOtype Like "*POLY*") Or (sOtype Like "*FEATURE*")) Then
      Err.Raise -4444444, , "Incorrect object type selected!"
      GoTo ResumeHere
    ''Remove the ElseIf section when the API allows Featurelines
    ElseIf sOtype Like "*FEATURE*" Then
      Err.Raise -4444445, , "Featurelines not currently supported, explode and try again!"
      GoTo ResumeHere
    End If
    Tindata.Name = sCurName
    Dim oTinSurf As AeccTinSurface
    Set oTinSurf = oSurfs.AddTinSurface(Tindata)
    Set oEnts(0) = oEnt1
    oTinSurf.Breaklines.AddStandardBreakline oEnts, "Interior Breakline", 0.5
    Set oEnts(0) = oEnt2
    oTinSurf.Breaklines.AddStandardBreakline oEnts, "Exterior Breakline", 0.5
    oTinSurf.Boundaries.Add oEnt2, "Exterior Boundary", aeccBoundaryOuter, True, 0.5
ResumeHere:
Select Case Err.Number
    Case Is = -4444444
      MsgBox Err.Description
    Case Is = -4444445
      MsgBox Err.Description
    Case Else
'      MsgBox Err.Description ''uncomment to test for the error thrown, comment out to run normally
End Select
Loop
End Sub

有人能再次解释一下我错过了什么吗?

mpeterson79 发表于 2010-6-25 09:48:53

您使用的是2011的64位版本吗?如果是这样,C3D互操作在安装期间不会注册。我将把REG文件附加到这篇文章中,您可以运行它来安装它们。如果没有,则忽略此部分…
在VBAIDE中,转到“工具”菜单,选择“引用”,取消选择与Civil有关的任何内容,向下滚动到Civil 8.0库,然后选择两个与土地相关的项目。

sinc 发表于 2010-6-28 10:31:44

谢谢Jeff_M-这成功了。
我现在只运行32位,但应该在本周末之前在64位Win7的新机器上运行,这样REG文件就会派上用场。

mpeterson79 发表于 2010-6-28 11:06:08

有人告诉我,在C3D 2011 x64上,简单地加载VBA模块会大大降低整个程序的速度。您可能最终需要将您的例程转换成. NET。
页: 1 [2]
查看完整版本: Civil 3D表面处理帮助!