乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 61|回复: 4

aeccpoint插入

[复制链接]

14

主题

57

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
113
发表于 2011-9-9 13:21:15 | 显示全部楼层 |阅读模式
尝试在选定的屏幕位置插入一个 aeccpoint,但我在
Set oPoints = g_oDocument时不断收到错误。此处的“错误。它是帮助文件的副本吗?那么为什么不
生成一个对象
感谢
john
Option Explicit
Public g_oCivilApp As AeccApplication
Public g_oDocument As AeccDocument
Public g_oAeccDatabase As AeccDatabase
Public AeccApp As AeccApplication
Public AeccDoc As AeccDocument
Public AeccDb As AeccDatabase
Public doc As AcadDocument
Private Sub CommandButton19_Click()
hide
' Always get the objects,因为支持 MDI。
  If (GetBaseCivilObjects() = False) then
Exit Sub
End if
Dim basePnt As Variant
Dim oPoints As AeccPoints
Dim oPoint1 As AeccPoint
Dim dLocation(0 To 2) As Double

basePnt = ThisDrawing.Utility.GetPoint(, “Select Location to Label”)

dLocation(0) = basePnt(0)
dLocation(1) = basePnt(1)
dLocation(2) = 0#
Set oPoints = g_oDocument.Points ''
'oPoint1.Name = “point1”
'oPoint1.RawDescription = “Point Description”
'oPoint1.Update

opoint.update
UserForm1.Show
End Sub

本帖以下内容被隐藏保护;需要你回复后,才能看到!

游客,如果您要查看本帖隐藏内容请回复
回复

使用道具 举报

71

主题

928

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1230
发表于 2011-9-9 14:09:33 | 显示全部楼层
错误是什么?另外,g_oDocument设置正确吗?当尝试设置Point对象时,它是有效对象吗?)?
回复

使用道具 举报

14

主题

57

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
113
发表于 2011-9-10 15:22:32 | 显示全部楼层

Jeff,
我收到一个错误,说在Set oPoint=g_oDocument.Points.Add(dLoc)处没有设置块变量。我在家测试了它
并删除了公共设置,它工作正常。我不确定为什么删除公共设置会在模块1中设置后做到这一点,但我的示例现在工作正常。
您是否碰巧有与下面相同但在vb点网中的示例或绘制简单线对齐的示例。
一如既往地感谢您帮助我想出这一点。
john
Private SubCommandButton20_Click()
隐藏
'检查以确保民用3D正在运行并获取民用对象
如果(GetBase文明对象=False)然后
Exit Sub
End如果
Dim dLoc(0 To 2)As Double
Dim oPoint As AeccPoint
Dim oPoint As AeccPoint
dLoc(0)=100: dLoc(1)=100: dLoc(2)=100#
设置oPoint=g_oDocument.Points.Add(dLoc)
oPoint.Update
UserForm1.Show
回复

使用道具 举报

71

主题

928

帖子

8

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1230
发表于 2011-9-10 22:03:42 | 显示全部楼层
嗨,约翰,如果公共对象在另一个模块中也被调暗了,VBA不喜欢那个IIRC。
这里有3个示例:使用COM设置一个点,使用COM向无站点对齐添加对齐,另一个用于. NET
  1. Imports Autodesk.AutoCAD.ApplicationServices
  2. Imports Autodesk.AutoCAD.DatabaseServices
  3. Imports Autodesk.AutoCAD.Runtime
  4. Imports Autodesk.AutoCAD.Geometry
  5. Imports Autodesk.Civil
  6. Imports Autodesk.Civil.ApplicationServices
  7. Imports Autodesk.Civil.Land.DatabaseServices
  8. Imports Autodesk.AECC.Interop.Land
  9. Imports Autodesk.AECC.Interop.UiLand
  10. Imports Autodesk.Civil.Land.DatabaseServices.Styles
  11. Public Class Class1
  12.      _
  13.     Public Sub MySetPoint()
  14.         Dim aeccapp As AeccApplication = New AeccApplicationClass()
  15.         aeccapp.Init(Application.AcadApplication)
  16.         Dim aeccdoc As AeccDocument = aeccapp.ActiveDocument
  17.         Dim pt As Point3d = New Point3d(100.0, 100.0, 100.0)
  18.         Dim aeccpt As AeccPoint = aeccdoc.Points.Add(pt.ToArray())
  19.         aeccapp = Nothing
  20.     End Sub
  21.      _
  22.     Public Sub MyAddAlignCOM()
  23.         Dim aeccapp As AeccApplication = New AeccApplicationClass()
  24.         aeccapp.Init(Application.AcadApplication)
  25.         Dim aeccdoc As AeccDocument = aeccapp.ActiveDocument
  26.         Dim alignstyle As AeccAlignmentStyle = aeccdoc.AlignmentStyles(0) ''get the first style in the collection
  27.         Dim alignlblstyle As AeccAlignmentLabelStyleSet = aeccdoc.AlignmentLabelStyleSets(0) ''get the first label style set in the collection
  28.         Dim layer As String = aeccdoc.Settings.DrawingSettings.ObjectLayerSettings.AlignmentLayer.Layer
  29.         Dim aeccalign As AeccAlignment = aeccdoc.AlignmentsSiteless.Add("MyFirstAlign", "0", alignstyle, alignlblstyle)
  30.         Dim pt1 As Point3d = New Point3d(100.0, 100.0, 100.0)
  31.         Dim pt2 As Point3d = New Point3d(300.0, 100.0, 100.0)
  32.         aeccalign.Entities.AddFixedLine1(pt1.ToArray(), pt2.ToArray())
  33.         aeccapp = Nothing
  34.     End Sub
  35.      _
  36.     Public Sub MyAddALignNET()
  37.         Dim civdoc As CivilDocument = CivilApplication.ActiveDocument
  38.         Dim alignstyle As ObjectId = civdoc.Styles.AlignmentStyles(0)
  39.         Dim alignlblstyle As ObjectId = civdoc.Styles.LabelSetStyles.AlignmentLabelSetStyles(0)
  40.         Dim layer As ObjectId = civdoc.Settings.DrawingSettings.ObjectLayerSettings.GetObjectLayerSetting(Autodesk.Civil.Settings.SettingsObjectLayerType.Alignment).LayerId
  41.         Dim alignid As ObjectId = Alignment.Create(civdoc, "MyFirstNETAlign", ObjectId.Null, layer, alignstyle, alignlblstyle)
  42.         Using tr As Transaction = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction()
  43.             Dim pt1 As Point3d = New Point3d(100.0, 100.0, 100.0)
  44.             Dim pt2 As Point3d = New Point3d(300.0, 100.0, 100.0)
  45.             Dim align As Alignment = tr.GetObject(alignid, OpenMode.ForWrite)
  46.             align.Entities.AddFixedLine(pt1, pt2)
  47.             tr.Commit()
  48.         End Using
  49.     End Sub
  50. End Class

回复

使用道具 举报

14

主题

57

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
113
发表于 2011-9-12 07:55:44 | 显示全部楼层
杰夫,我不知道VBA不喜欢IIRC。我只是复制了一些旧的代码,使这一次例行公事,从来没有想过公共dim。
我想我很幸运,因为我以前从未遇到过。
非常感谢您提供的. net样本。我试着找了几次时间把我的日常工作转移到点网上,但是当我正在学习点网的时候,工作似乎总是变得疯狂,然后一个月后,我忘记了我前一个月做的所有事情。
我大部分时间都在努力调试,当我试图在. net中调试时,我崩溃了,因为我不知道如何捕捉. net错误。当我崩溃系统时,不得不一次又一次地启动autocad,这令人沮丧........我会及时到达那里。
一如既往地感谢您的帮助和理解。我知道一直要处理初学者的问题并不容易。
约翰
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-6-30 17:11 , Processed in 1.116145 second(s), 63 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表