TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: ahazen on June 16, 2015, 11:34:30 AM
-
I have hyperlinks to attach with names like 360-001.html or www.website.com/360-001. I was wondering if I could get help automating the hyperlinking process for these blocks. So block with attribute "001" would automatically be hyperlinked with www.website.com/360-001 when the command is run.
-
Is the attribute TAG named "001" or is that the value for the attribute? .. BTW .. welcome to TheSwamp :)
HERE (http://www.theswamp.org/index.php?topic=47538.msg525340#msg525340)'s a thread you can reference for adding a URL to an object.
-
Thanks for the welcome! I hope to learn :lol:. The TAG is 001. In this specific situation the attribute value is 360. I want to utilize the tag.
-
Wait. I meant I want the Value for the attribute. Sorry, I flipped those mentally. The tag is 360 and the value is 001.
-
Give this a try:
(defun c:puturl
(/ _ss2l tag val
) (defun _ss2l
(ss
/ n result
) )
)
(foreach ename
(_ss2l
(ssget ":L" '
((0 .
"insert") (66 .
1)))) )
(setq val
(strcat "www.website.com/" tag
"-" val
)) )
'(1002 . "{")
'(1002 . "{")
'(1071 . 0)
'(1002 . "}")
'(1002 . "}")
)
)
)
)
)
)
)
)
-
That is working, I'll make some edits and get back to you, but that gave me the parts I was missing!
Thanks, that's a positive first impression to the forum!
-
Glad to help :)
-
Another, using ActiveX:
(defun c:batchurl
( / h i o s v
) )
)
)
)
)
The above will only add a new hyperlink if the block has no existing hyperlinks to avoid duplication.
-
@ ronjonp:
You are using entmod twice. I think the first call is not necessary.
-
@ ronjonp:
You are using entmod twice. I think the first call is not necessary.
Ahh yes .. that carried over from the other thread referenced to keep an existing hyperlink but change the text shown. Updated above.
-
Ahh yes .. that carried over from the other thread referenced to keep an existing hyperlink but change the text shown. Updated above.
I don't know the thread you are referring to. But whenever you write new Xdata for an aplication all the old data is automatically removed. You cannot update a single item or append data. So I think that in the 'other thread' there is then also a superfluous call to entmod. :wink:
-
Ahh yes .. that carried over from the other thread referenced to keep an existing hyperlink but change the text shown. Updated above.
I don't know the thread you are referring to. But whenever you write new Xdata for an aplication all the old data is automatically removed. You cannot update a single item or append data. So I think that in the 'other thread' there is then also a superfluous call to entmod. ;)
You are correct it is superfluous. I'll try to be better in the future :P We also need to check that PE_URL is registered before writing xdata ( updated in code above ) .