• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Visual LISP, AutoLISP and General Customization

    Reply
    Contributor
    vrod2000
    Posts: 15
    Registered: ‎03-08-2011

    Re: using Lisp to add a hyperlink to a specific attribute

    03-17-2011 06:43 AM in reply to: pbejse

    Sweet!

     

    I'll try it out soon and let you know how it goes!

     

    Right now, I'm thinking of starting my weekend early, so it might not be until Monday that I check it out.

     

    thanks for the code, I'm sure I will get it to work.

     

     

    Please use plain text.
    Contributor
    vrod2000
    Posts: 15
    Registered: ‎03-08-2011

    Re: using Lisp to add a hyperlink to a specific attribute

    03-21-2011 05:42 AM in reply to: pbejse

    I tried it out this morning....the program works using my drawing list, however it is not deleting the existing hyperlinks.

     

    Have you tested that part out?  As an example, make a small drawing list with values, then change it and rerun the program.

     

     

    Please use plain text.
    *Expert Elite*
    Posts: 2,070
    Registered: ‎11-24-2009

    Re: using Lisp to add a hyperlink to a specific attribute

    03-21-2011 06:05 AM in reply to: vrod2000

    Of course I did,       :smileyhappy:

    granting the attribute  a "clean" one or just one count of hyperlink  , tell you what

     

    (defun c:givemethecount nil
    (vl-load-com)
    (print 
    (vla-get-count
    (vla-get-hyperlinks 
    	(vlax-ename->vla-object (car (nentsel))))))
      (princ)
      )

     Hit the attribute with this one and tell me what it says

     

    or better yet.. post the drawing in here

     

    Please use plain text.
    *Expert Elite*
    Posts: 2,070
    Registered: ‎11-24-2009

    Re: using Lisp to add a hyperlink to a specific attribute

    03-21-2011 06:40 AM in reply to: pbejse

    oops. :smileysurprised:

    my bad

     

    I think i know what happen.

    Change this

     

      (strcat (cadr hpt) (car hpt) "*.dwg)

     

    to

     

      (strcat (cadr hpt) (car hpt) ".dwg")

     

    with the code before when you pick the attribute with givethepath thingy. i would show you a string with filename *.dwg

    If by somehow you get a value more that 1 with givemethecount, i think i have an idea how to fix that

     

     

     

     

     

    Please use plain text.
    Contributor
    vrod2000
    Posts: 15
    Registered: ‎03-08-2011

    Re: using Lisp to add a hyperlink to a specific attribute

    03-21-2011 07:34 AM in reply to: vrod2000

    It is still not replacing the existing hyperlinks. This means if a drawing reference changes, it will still point to the prior hyperlink.    hmmmm.....

     

     

    Please use plain text.
    Contributor
    vrod2000
    Posts: 15
    Registered: ‎03-08-2011

    Re: using Lisp to add a hyperlink to a specific attribute

    03-21-2011 07:51 AM in reply to: vrod2000

    I ran that program.  The count is 5.  There must be some links ontop each other. 

     

    It can erase all hyperlinks for the matching attribute. That would be fine with me.

    Also, if the attribute has no value, the hyperlink should be erased. (that way if a reference is removed, the hyperlink will go away).

     

    attached is the sample drawing.

    Please use plain text.
    *Expert Elite*
    Posts: 2,070
    Registered: ‎11-24-2009

    Re: using Lisp to add a hyperlink to a specific attribute

    03-21-2011 08:32 PM in reply to: vrod2000

    Got the file, tested it a dozen times for you

     

    (defun c:HyperL  (/ blks dwglist str nw_lst blk hpt htp)
      (vl-load-com)
      (if (setq blks (ssget '((0 . "INSERT") (66 . 1))))
        (progn
          (setq DWGLST (open "c:/scripts/drawings/dwglst.txt" "r"))
          (while (setq str (read-line DWGLST))
            (if (not (eq str "EOF"))
              (setq nw_lst (cons (list (strcase str) (read-line DWGLST)) nw_lst))))
          (close Dwglst)
          (while (setq blk (ssname blks (setq cntr (1+ cntr))))
            (foreach
               at_str  (vlax-invoke
                         (vlax-ename->vla-object blk)
                         'GetAttributes)
              (if
                (setq hpt (assoc (strcase (vla-get-textstring at_str)) nw_lst))
                 (progn
                   (if (> (vla-get-count
                            (setq htp (vla-get-hyperlinks at_str)))
                          0)
                     (vlax-for cn htp
                     (vla-delete cn))) ;if Hyperlink Exist
                   (vla-add
                     (vla-get-hyperlinks at_str)
                     (strcat (cadr hpt) (car hpt) ".dwg")
                     "File Hyperlink")))    ;if
              );foreach
            );while
          );progn
        );if ssget
      (princ))

     

    I think  now its all good :smileyhappy:

    Please use plain text.
    Contributor
    vrod2000
    Posts: 15
    Registered: ‎03-08-2011

    Re: using Lisp to add a hyperlink to a specific attribute

    03-22-2011 08:02 AM in reply to: vrod2000

    :smileyvery-happy:

     

    That did it!!!!   I just need to modify it, so it will simply make a selection set of all symbols on the drawing (no picking required).

     

    This is something I'll work on in the next week. It is the least I can do.

     

    Very nice so far!

    Please use plain text.
    New Member
    dharandesign
    Posts: 2
    Registered: ‎04-21-2011

    How to add filepath in the cad drawing attribute using lisp

    04-21-2011 02:51 AM in reply to: vrod2000

    How to add filepath in the cad drawing attribute using lisp ?

      
    Can anyone help me in this?

     

    Please use plain text.
    *Expert Elite*
    Posts: 2,070
    Registered: ‎11-24-2009

    Re: How to add filepath in the cad drawing attribute using lisp

    04-25-2011 05:34 AM in reply to: dharandesign

    You mean the path of the current drawing?

     

    (defun c:AddPrefix  (/ String)
      (vl-load-com)
      (cond (
        (and
         (setq sTring (car (nentsel "\nSelect Attribute:")))
         (eq (cdr (assoc 0 (entget String))) "ATTRIB")
         (vla-put-textstring
           (vlax-ename->vla-object String)
           (strcat
             (getvar 'Dwgprefix)
             (vla-get-textstring (vlax-ename->vla-object String)))))
         )
        )
      )

     Hope this helps

     

     You need to invoke regen

     

    Please use plain text.