bigmaz 发表于 2022-7-6 22:27:36

C3D路线长度报告

你好
 
我正在尝试使用此报告:
 
http://blog.civil3dreminders.com/2012/03/alignment​-长度报告。html
 
但这些文件似乎适用于C3D 2011,不会与2012一起使用。最后有一些东西解释了如果您使用的是差异版本的C3D,该怎么办。我只是想知道是否有人可以调整文件,使其在2012年工作?我真的不擅长VBA。太令人困惑了。
 
干杯
马丁

SLW210 发表于 2022-7-6 22:34:09

您有Microsoft Visual Basic for Applications模块吗?

bigmaz 发表于 2022-7-6 22:35:12

是的,我下载并安装了它。

BlackBox 发表于 2022-7-6 22:41:40

伙计们,
 
作者最初是用VBA编写代码的。
 
上面链接的博客文章演示了如何使用VB实现类似的插件。NET(因此出现了Visual Studio屏幕截图)。不需要VBA模块。
 
 
实际上,插件的工作原理与宣传的完全一样。。。刚刚使用Civil 3D 2012进行了测试。。。我个人认为这比必要的工作要多(使用Microsoft.Office.Interop.Excel库,当写入一个简单的CSV时可以),但它仍然有效。

BlackBox 发表于 2022-7-6 22:46:16

... 此外,FWIW-我*相信*因为这最初是通过ActiveX COM API完成的,所以仍然有一种方法可以使用Visual LISP(它也使用ActiveX COM API)来完成。
 
查看AeccXUiLand。AeccApplication对象:
 

(vl-load-com)

(defun c:C3dComApi (/ file)
(if
   (setq
       file (findfile
            (strcat
                (vl-registry-read
                  (strcat "HKEY_LOCAL_MACHINE\\"
                        (if vlax-user-product-key                  ; If 2013
                            (vlax-user-product-key)                  ; Use 2013 function
                            (vlax-product-key)                         ; Use legacy function
                        )
                  )
                  "ACADLOCATION"
                )
                "\\help\\civil_api_activex_reference.chm"
            )
            )
   )
   (startapp "explorer" file)
   (prompt "\n** File not found ** ")
)
(princ)
)

BlackBox 发表于 2022-7-6 22:47:43

这是一个最近的(尽管不相关)示例,请参阅第4篇:
 
http://www.theswamp.org/index.php?topic=42585.0

bigmaz 发表于 2022-7-6 22:50:45

当我尝试运行该程序时,它会出现以下错误:
 

BlackBox 发表于 2022-7-6 22:55:17


 
... 这是因为插件引用了Microsoft。办公室互操作。Excel库,并且在您的系统上找不到它(依赖引用)。我将看看我能做些什么来提供一个不具有这种依赖性的自适应,而是使用basic。改为CSV。

bigmaz 发表于 2022-7-6 22:57:46

 
那太好了,非常感谢你的帮助

BlackBox 发表于 2022-7-6 23:04:00

我喜欢事情比我想象的简单的时候。。。Autodesk似乎很友善地将路线对象特性公开给Visual LISP;没有Aecxuiland。此任务所需的AeckApplication接口对象。
 
享受
 

(vl-load-com)

(defun c:ALR () (c:AlignmentsLengthReport))
(defun c:AlignmentsLengthReport (/ *error*)
(princ "\rALIGNMENTSLENGTHREPORT ")

(defun *error* (msg)
   (if file
   (close file)
   )
   (if oShell
   (vlax-release-object oShell)
   )
   (cond ((not msg))                                                   ; Normal exit
         ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
         ((princ (strcat "\n** " msg " ** ")))                         ; Fatal error, display it
   )
   (princ)
)

((lambda (acApp / ss oShell filePath file alignmentName alignmentLength)
    (if (and (setq ss (ssget "_x" '((0 . "AECC_ALIGNMENT"))))
             (setq oShell (vla-getinterfaceobject
                            acApp
                            "Shell.Application"
                        )
             )
             (setq filePath
                  (strcat
                      (vl-filename-directory
                        (vl-filename-mktemp)
                      )
                      "\\Alignments Length Report_"
                      (menucmd
                        "M=$(edtime,$(getvar,date),YYYY-MO-DD)"
                      )
                      ".csv"
                  )
             )
             (princ "\nWorking, please wait... ")
             (princ)
      )
      (progn
      (setq file (open filePath "w"))
      (write-line "Civil 3D Drawing:" file)
      (write-line
          (strcat (getvar 'dwgprefix) (getvar 'dwgname))
          file
      )
      (write-line "" file)
      (write-line "Alignment Name:,Length:" file)
      (vlax-for x (setq ss (vla-get-activeselectionset (vla-get-activedocument acApp)))
          (if (and (setq alignmentName (vlax-get x 'name))
                   (setq alignmentLength (rtos (vlax-get x 'length)))
            )
            (write-line (strcat alignmentName "," alignmentLength) file)
          )
      )
      (vla-delete ss)
      (princ "Done.")
      (setq file (close file))
      (vlax-invoke oShell 'open filePath)
      (*error* nil)
      )
      (cond
      (ss
         (*error*
         "Error: Unable to create \"Shell.Application\" Object"
         )
      )
      ((*error* "No alignments found"))
      )

    )
)
   (vlax-get-acad-object)
)
)
页: [1] 2
查看完整版本: C3D路线长度报告