Autodesk论坛中看到的一段代码,留存备用
(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语言的,
刚搜索了一下其中个别方法,
可以用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; }