如果这段代码不符合你的预期,那么我需要你张贴那幅画。然而,我认为这是你想要的。注意,这里只是使用了一个通用的错误陷阱,我强烈建议做一些更健壮的事情.....
您将需要确保在VBA项目中设置Civil Land & LandUI参考。
- Sub test()
- Dim oApp As AeccApplication
- Dim oDoc As AeccDocument
- Dim oSurfs As AeccSurfaces
- Set oApp = Application.GetInterfaceObject("AeccXUiLand.AeccApplication.5.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 oPoly1 As Acad3DPolyline
- Dim opoly2 As Acad3DPolyline
- Dim oEnts(0) As AcadEntity
- Do Until Err.Number 0
- iCount = iCount + 1
- sCurName = "Bldg " & Format(iCount, "000")
- On Error GoTo ResumeHere
- ThisDrawing.Utility.GetEntity oEnt1, vPick, vbCr & "Select inside pline: "
- Set oPoly1 = oEnt1
- ThisDrawing.Utility.GetEntity oEnt2, vPick, vbCr & "Select outside pline: "
- Set opoly2 = oEnt2
- Tindata.Name = sCurName
- Dim oTinSurf As AeccTinSurface
- Set oTinSurf = oSurfs.AddTinSurface(Tindata)
- Set oEnts(0) = oPoly1
- oTinSurf.Breaklines.AddStandardBreakline oEnts, "Interior Breakline", 0.5
- Set oEnts(0) = opoly2
- oTinSurf.Breaklines.AddStandardBreakline oEnts, "Exterior Breakline", 0.5
- oTinSurf.Boundaries.Add opoly2, "Exterior Boundary", aeccBoundaryOuter, True, 0.5
- ResumeHere:
- 'If Err Then MsgBox Err.Description ''uncomment to test for the error thrown
- Loop
- End Sub
|