乐筑天下

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

[编程交流] 如何获取激活的AutoCAD项目

[复制链接]

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 14:17:53 | 显示全部楼层 |阅读模式
你好
 
我需要使用VBA获得AutoCAD中激活项目的路径。我找到了autocad API(ace\u getactiveproject)来查找路径,但我不知道如何在VBA中使用它。。
他们有没有其他方法可以走这条路??
 
提前感谢
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 14:39:16 | 显示全部楼层
开发人员帮助(ActiveX和VBA参考)有一个很好的示例。在帮助文件中搜索SetProjectFilePath示例。
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 14:50:40 | 显示全部楼层
感谢您的输入
 
我还有一个问题。我在Autocad electrical中创建了一个新项目。是否可以使用VBA重设Activeproject名称?
 
谢谢
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 15:00:10 | 显示全部楼层
这是否返回正确的名称?
 
currProjName=此绘图。GetVariable(“项目名称”)
回复

使用道具 举报

1

主题

3

帖子

2

银币

初来乍到

Rank: 1

铜币
5
发表于 2022-7-6 15:14:24 | 显示全部楼层
什么时候用这个
currProjName=此绘图。GetVariable(“PROJECTNAME”)语句,它正在返回empy字符串(currProjName=“”)
 
如果我使用“123”(我的活动项目)而不是PROJECTNAME,我会得到错误“error get system variable”
请帮帮我
 
谢谢
回复

使用道具 举报

10

主题

973

帖子

909

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 2022-7-6 15:24:24 | 显示全部楼层
看来我提到的例子有错误。
试试下面修改过的例子,看看这是否有用。
 
  1. Sub Example_SetProjectFilePath()
  2.    ' This example finds the current project file information, changes
  3.    ' that information, and finally resets the information back to the
  4.    ' original values.
  5.    
  6.    Dim preferences As AcadPreferences
  7.    Set preferences = ThisDrawing.Application.preferences
  8.    
  9.    ' Get the current project file information
  10.    Dim currProjPath As String
  11.    Dim currProjName As Variant
  12.    currProjName = ThisDrawing.GetVariable("PROJECTNAME")
  13.    If currProjName <> "" Then
  14.        currProjPath = preferences.Files.GetProjectFilePath(currProjName)
  15.    End If
  16.    If currProjPath = "" Then
  17.        MsgBox "There is no current project file or path. ", , "SetProjectFilePath Example"
  18.    Else
  19.        MsgBox "The current project file path is: " & currProjPath, , "SetProjectFilePath Example"
  20.        ' Set new project file information.
  21.        ' Change drive/path as necessary to match your system
  22.        Dim newProjPath As String
  23.        newProjPath = "C:/AutoCAD/"
  24.       
  25.        preferences.Files.SetProjectFilePath currProjName, newProjPath
  26.        MsgBox "The new project file path is: " & newProjPath, , "GetProjectFilePath Example"
  27.       
  28.        ' Reset the project file information
  29.        preferences.Files.SetProjectFilePath currProjName, currProjPath
  30.        MsgBox "The project file path has been reset to: " & currProjPath, , "GetProjectFilePath Example"
  31.    End If
  32.    
  33. End Sub
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-5 03:14 , Processed in 0.409736 second(s), 75 queries .

© 2020-2025 乐筑天下

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