欢迎来到我的博客
Civil 3D开发与应用,欢迎加入QQ群:484124761
AutoCAD开发,欢迎加入QQ群:193522571

Autodesk论坛中看到的一段代码,留存备用

原帖

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(defun c:test ()
 
  (setq ad (_GetAeccDocument))      ;Get the Aecc Document
 
  (setq s (vlax-get-property ad 'Settings))
                    ;Get the aecc settings from the Aecc Document                  
 
  (setq ds (vlax-get-property s 'DrawingSettings))
                    ;Get the Drawing Settings from the aecc settings
  (setq as (vlax-get-property ds 'AbbreviationSettings))
                    ;Get the abbreviation settings from the drawing settings
  (setq alignAbbrev (vlax-get-property as 'AlignmentAbbreviations))
                    ;Get the Alignment abbreviations from the abbreviation settings
  (setq alignBeg (vlax-get-property alignAbbrev 'AlignmentBeginning))
                    ;Get the alignment beginning abbreviation from the alignment abbreviations
  (princ (strcat "\nCurrent AlignmentBeginning Abbreviation: "
         alignBeg
     )
  )                 ;Print the current value of the alignment beginning abbreviation
  (vlax-put-property alignAbbrev 'AlignmentBeginning "BEG")
                    ;Set the value of the Alignment Beginning abbreviation
  (princ
    (strcat "\nNew AlignmentBeginning Abbreviation: "
        (vlax-get-property alignAbbrev 'AlignmentBeginning)
    )
  )                 ;Print the new value of the alignment beginning abbreviation
  (princ)               ;exit clean
)
 
(defun _GetAeccDocument ()
  (setq C3D (strcat "HKEY_LOCAL_MACHINE\\"
            (if vlax-user-product-key
              (vlax-user-product-key)
              (vlax-product-key)
            )
        )
    C3D (vl-registry-read C3D "Release")
    C3D (substr
          C3D
          1
          (vl-string-search "." C3D (+ (vl-string-search "." C3D) 1))
        )
    C3D (vla-getinterfaceobject
          (vlax-get-acad-object)
          (strcat "AeccXUiLand.AeccApplication." C3D)
        )
  )
  (vlax-get-property C3D 'ActiveDocument)
)

 

 

2020年2月19日

留存这段代码是准备翻译成.net语言的,

刚搜索了一下其中个别方法,

vlax-product-key

可以用Autodesk.AutoCAD.Runtime.SystemObjects.DynamicLinker.ProductKey

或者Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.Current.UserRegistryProductRootKey

原帖在此,上面的方法是否可行还没进行验证。

 

2022-03-25 09:53:38 

 

这个帖子里已经有了.net代码

复制代码
        /// <summary>
        /// module must be "Land", "Pipe", "Roadway", or "Survey"
        /// </summary>
        /// <param name="module"></param>
        /// <returns>AeccApp string</returns>
        public static dynamic GetAeccApp(string module)
        {
            var rootkey = HostApplicationServices.Current.UserRegistryProductRootKey;
            var hj = Registry.LocalMachine.OpenSubKey(rootkey);
            var c3d = (string)hj.GetValue("Release");
            c3d = c3d.Substring(0, c3d.IndexOf(".", (c3d.IndexOf(".") + 1)));
            hj.Close();
            c3d = "AeccXUi" + module + ".Aecc" + (module == "Land" ? "" : module) + "Application." + c3d;
            dynamic acadApp = Application.AcadApplication;
            dynamic aeccApp = acadApp.GetInterfaceObject(c3d);
            return aeccApp;
        }
复制代码

 

posted @   david96007  阅读(495)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示