Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Contributor
vrod2000
Posts: 15
Registered: ‎03-08-2011
Message 21 of 31 (865 Views)

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.

 

 

Contributor
vrod2000
Posts: 15
Registered: ‎03-08-2011
Message 22 of 31 (849 Views)

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.

 

 

*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 23 of 31 (846 Views)

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

 

*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 24 of 31 (840 Views)

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

 

 

 

 

 

Contributor
vrod2000
Posts: 15
Registered: ‎03-08-2011
Message 25 of 31 (833 Views)

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.....

 

 

Contributor
vrod2000
Posts: 15
Registered: ‎03-08-2011
Message 26 of 31 (829 Views)

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.

*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 27 of 31 (810 Views)

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:

Contributor
vrod2000
Posts: 15
Registered: ‎03-08-2011
Message 28 of 31 (799 Views)

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!

New Member
dharandesign
Posts: 2
Registered: ‎04-21-2011
Message 29 of 31 (753 Views)

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?

 

*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 30 of 31 (735 Views)

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

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community