到目前为止,我们班只教了我一门语言。但是,现在我有起草工作要做,不得不从有趣但令人沮丧的Lisp工作中休息一下。 *假设*属性值正确,那么打开该地址的浏览器就太容易了眨眼:
给我一分钟。。。。 修改了打开internet浏览器的代码:
(defun c:FOO(/ eName blockObj tagString)
(vl-load-com)
(if (and (setq eName
(car (entsel "\n>>Select an Attributed Block: ")))
(= "INSERT" (cdr (assoc 0 (entget eName))))
(setq blockObj (vlax-ename->vla-object eName))
(vlax-method-applicable-p blockObj 'getattributes))
(foreach x(vlax-invoke blockObj 'getattributes)
(if (= "WEBSITE" (setq tagString (vla-get-tagstring x)))
(command "._browser" (vla-get-textstring x)))))
(princ))
我有一点时间,所以希望你能从这段喃喃自语中找到值得一读的东西:
(defun c:test ( / entity )
;; Define function, localise variable 'entity' used.
;; You can try to think of a better function syntax :-)
(if ;; IF the following expression returns True
;; (any non-nil value in fact, string, number you name it - just not 'nil')
;; we will proceed to the 'then' expression...
;; IF 'Test' Expression Starts Here {
(and ;; All of the expressions enclosed must return True
;; for the AND function to return True. AND will stop
;; evaluating expressions as soon as an expression returns
;; False.
(setq entity (car (entsel "\nSelect Attributed Block: ")))
;; Prompt user for selection.
;; If user misses, entsel returns nil, hence (car (entsel)) also returns nil.
;;
;; Else, if user picks object, entsel returns list of entity and picked point
;;
;; (<Entity> (x y z)), so (car (entsel)) returns <Entity>
(eq "INSERT" (cdr (assoc 0 (entget entity))))
;; Check that our user has picked a block and not some other unwanted
;; object like a pesky line.
(= 1 (cdr (assoc 66 (entget entity))))
;; Check that the block is attributed, the 66 code means that ATTRIB
;; entities follow the block entity terminated by a SEQEND entity.
;; It is these ATTRIBute entities that we will query.
;; Source: http://autodesk.com/techpubs/autocad/acad2000/dxf/insert_dxf_06.htm
) ;; End AND
;; } IF 'Test' Expression Ends Here
;; All of our conditions have returned True, so lets rock and roll...
;; IF 'Then' Expression Starts Here {
(while ;; While the following expression returns a non-nil value:
(eq "ATTRIB" (cdr (assoc 0 (entget (setq entity (entnext entity))))))
;; We now look at the entity following the INSERT entity by using the
;; ENTNEXT function (pretty self-explanatory, 'next entity' so we use 'ent next'
;; We've checked that the INSERT entity has ATTRIBute entities following it
;; (DXF code 66=1) hence we know that the loop will run through at least once.
;; So: WHILE we are dealing with an ATTRIB entity and not a SEQEND Entity...
(princ (strcat "\nAttribute: " (cdr (assoc 2 (entget entity)))))
;; Print the Attribute TAG string to the screen for all to see
;; (DXF code 2 of the ATTRIB entity)
;; Source: http://autodesk.com/techpubs/autocad/acad2000/dxf/attrib_dxf_06.htm
(princ (strcat "Value: " (cdr (assoc 1 (entget entity)))))
;; Print the Attribute VALUE string to the screen for all to see
;; (DXF code 1 of the ATTRIB entity)
;; Source: You can't have missed it if you studied the previous comment ;-)
) ;; End WHILE
;; Doh! No 'Else' expression to evaluate...
) ;; End IF
(princ)
;; Lets keep the return of the last function a secret and exit quietly
) ;; End DEFUN
*薰衣草*是一个美丽的颜色对你李。。。这真的为你刚刚分享的知识轰炸增加了一种“软接触”。
别开玩笑了,解释得很好的文档(一如既往!):眨眼: 调用浏览器的另一种方法
(defun c:FooBar ( / entity site elist )
(if (and
(setq entity (car (entsel "\nSelect an Attributed Block: ")))
(eq "INSERT" (cdr (assoc 0 (entget entity))))
(= 1 (cdr (assoc 66 (entget entity))))
(progn
(while
(and
(eq "ATTRIB"
(cdr
(assoc 0
(setq elist
(entget (setq entity (entnext entity)))
)
)
)
)
(not site)
)
(if (eq "WEBSITE" (cdr (assoc 2 elist)))
(setq site (cdr (assoc 1 elist)))
)
)
site
)
)
(LM:NavigateTo site)
)
(princ)
)
(defun LM:NavigateTo ( url / ie )
;; © Lee Mac 2010
(vl-load-com)
(if (setq ie (vlax-create-object "InternetExplorer.Application"))
(progn
(vlax-put ie 'Visible :vlax-true)
(vlax-invoke ie 'Navigate url)
(vlax-release-object ie)
)
)
)
呵呵谢谢
是的,当然。我一直忽略了ActiveX的“完整”功能(超出应用程序范围)。
今天是我第一次尝试,但我无法正确调用LaunchBrowserDialog方法。命令行也没有提供有用的反馈。我现在要去上班了,但它困扰着我,我无法让它工作。 哦我的单词
伦德曼,你太棒了。
李,我会学习所有这些东西,希望能靠我自己做到这一点。
当然,你知道我会继续调整,这样里面的东西就是我的了。这是为一个类编写的,当学习过程在我脑海中翻腾时,至少有些代码也需要我自己编写。英雄联盟
要学的东西太多,时间太少。。。
欢迎来到阿拉斯加州。
就Visual LISP而言,就像Renderman的例子一样——虽然它看起来很直观,因为函数是英文的,而不是DXF语言,但我不会完全忽略Vanilla AutoLISP方法。它们绝对值得知道。有些情况在VL中编码得更好,有些情况在Vanilla中更简洁(以字典操作为例),执行速度更快(以实体创建为例),而VL可以在AutoCAD“盒子”之外努力进入其他支持OLE自动化的应用程序。
页:
1
[2]