Author Topic: take attribute and create hyperlink and attach to block  (Read 4189 times)

0 Members and 1 Guest are viewing this topic.

Drafter X

  • Swamp Rat
  • Posts: 578
take attribute and create hyperlink and attach to block
« on: April 12, 2012, 11:45:58 AM »
Hey all,
I don't normally beg code, but this is one that probably wouldn't be to hard for you gurus and a lot of people would be able to make use of.  I cant code my way out of a paper bag so its beyond me though.

What I would like to do is have a command that lets you click on a section marker that has attributes (detail number and sheet). It would read the sheet attribute and create a hyperlink on the block to pop to that sheet view.  It would just be a nice touch for navigating once these things are dwfs for clients.  I did a search but didn't find this and as most of my work for clients doesn't use SSM that option isn't available.

Any thoughts on how to accomplish this?  I can probably cludge something together given a starting point, any advice?
CadJockey Militia Commander

Drafter X

  • Swamp Rat
  • Posts: 578
Re: take attribute and create hyperlink and attach to block
« Reply #1 on: April 12, 2012, 12:46:07 PM »
Thanks Mark,

Also, I do know how to do this manually with the hyperlink command, would just love to be able to do it automatically. I tried with diesel but I cant pull the attribute out of the block with diesel.
CadJockey Militia Commander

kruuger

  • Swamp Rat
  • Posts: 637
Re: take attribute and create hyperlink and attach to block
« Reply #2 on: April 12, 2012, 04:32:52 PM »
Hey all,
I don't normally beg code, but this is one that probably wouldn't be to hard for you gurus and a lot of people would be able to make use of.  I cant code my way out of a paper bag so its beyond me though.

What I would like to do is have a command that lets you click on a section marker that has attributes (detail number and sheet). It would read the sheet attribute and create a hyperlink on the block to pop to that sheet view.  It would just be a nice touch for navigating once these things are dwfs for clients.  I did a search but didn't find this and as most of my work for clients doesn't use SSM that option isn't available.

Any thoughts on how to accomplish this?  I can probably cludge something together given a starting point, any advice?
when you click hyperlink you want to navigate only to correct layout or viewport with detail number ?
with second option it might be a problem. we can refer to detail marker but not to viewport (we don't know where it is).
kruuger


Drafter X

  • Swamp Rat
  • Posts: 578
Re: take attribute and create hyperlink and attach to block
« Reply #3 on: April 12, 2012, 04:40:19 PM »
Easier then that, just want to go to the sheet.  The person can find the correct detail easy enough with that.  So I only need the SHEET attribute out of the block and have that as the target.

I can do it manually with the hyperlink command of course, just looking to automate it.
CadJockey Militia Commander

kruuger

  • Swamp Rat
  • Posts: 637
Re: take attribute and create hyperlink and attach to block
« Reply #4 on: April 12, 2012, 04:53:52 PM »
Easier then that, just want to go to the sheet.  The person can find the correct detail easy enough with that.  So I only need the SHEET attribute out of the block and have that as the target.

I can do it manually with the hyperlink command of course, just looking to automate it.
give me your block name, attribute tags.
it shouldn't be a big problem (i hope)
k.

ronjonp

  • Needs a day job
  • Posts: 7529
Re: take attribute and create hyperlink and attach to block
« Reply #5 on: April 12, 2012, 05:43:20 PM »
When you refer to "sheet" do you mean the layout tabs? A sample drawing may help  :-)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Drafter X

  • Swamp Rat
  • Posts: 578
Re: take attribute and create hyperlink and attach to block
« Reply #6 on: April 12, 2012, 06:00:47 PM »
ah sorry, yes, just the layout tab name.  I'll get a sample drawing together and get it up when I can.
CadJockey Militia Commander

kruuger

  • Swamp Rat
  • Posts: 637
Re: take attribute and create hyperlink and attach to block
« Reply #7 on: April 12, 2012, 06:11:33 PM »
ah sorry, yes, just the layout tab name.  I'll get a sample drawing together and get it up when I can.
try this one:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:HYP (/ BLK TAG ss n ob# sh al)
  2.   (setq BLK "BL-PLAN-RIGHT" ; change to correct block name
  3.         TAG "PAGE-NR"       ; change to correct attribute tag
  4.   )
  5.   (if
  6.     (setq ss
  7.       (ssget "_X"
  8.         (append
  9.          '((0 . "INSERT"))
  10.           (list
  11.             (cons 2 (strcat "`*U*," BLK))
  12.           )
  13.         )
  14.       )
  15.     )
  16.     (progn
  17.       (repeat (setq n (sslength ss))
  18.         (if
  19.           (wcmatch
  20.             (strcase
  21.               (vla-Get-EffectiveName
  22.                 (setq ob#
  23.                   (vlax-ename->vla-object
  24.                     (ssname ss (setq n (1- n)))
  25.                   )
  26.                 )
  27.               )
  28.             )
  29.             (strcase BLK)
  30.           )
  31.           (progn
  32.             (setq sh (LM:vl-GetAttributeValue ob# TAG))
  33.             (if (member sh (layoutlist))
  34.               (vla-Add
  35.                 (vla-Get-Hyperlinks ob#)
  36.                 "" "" (strcat "," sh)
  37.               )
  38.               (setq al (cons (strcat sh "\n") al))
  39.             )
  40.           )
  41.         )
  42.       )
  43.       (if al
  44.         (alert
  45.           (strcat
  46.             "Wrong markers:\n"
  47.             (apply 'strcat al)
  48.           )
  49.         )
  50.       )
  51.     )
  52.     (princ "\n** No section markers in drawing **")
  53.   )
  54.   (princ)
  55. )
  56. ;;----------------=={ Get Attribute Value }==-----------------;;
  57. ;;                                                            ;;
  58. ;;  resurns the attribute value associated with the specified ;;
  59. ;;  tag, within the supplied block, if present.               ;;
  60. ;;------------------------------------------------------------;;
  61. ;;  Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       ;;
  62. ;;------------------------------------------------------------;;
  63. ;;  Arguments:                                                ;;
  64. ;;  block - VLA Block Reference Object                        ;;
  65. ;;  tag   - Attribute TagString                               ;;
  66. ;;------------------------------------------------------------;;
  67. ;;  resurns:  Attribute TextString, else nil                  ;;
  68. ;;------------------------------------------------------------;;
  69. (defun LM:vl-GetAttributeValue ( block tag )
  70.     (setq tag (strcase tag))
  71.     (vl-some
  72.         (function
  73.             (lambda ( attrib )
  74.                 (if (eq tag (strcase (vla-get-Tagstring attrib)))
  75.                     (vla-get-TextString attrib)
  76.                 )
  77.             )
  78.         )
  79.         (vlax-invoke block 'GetAttributes)
  80.     )
  81. )
change block name and tag as needed.
k.
« Last Edit: April 12, 2012, 06:15:39 PM by kruuger »

Drafter X

  • Swamp Rat
  • Posts: 578
Re: take attribute and create hyperlink and attach to block
« Reply #8 on: April 12, 2012, 07:19:56 PM »
Lee, just.. WOW, that does all of them in a mass strike, that's amazing.
Does exactly what I was after only even better, I thankee.

Do you mind if I point people to this thread? I have a feeling a lot of folks would find this very useful.
CadJockey Militia Commander

kruuger

  • Swamp Rat
  • Posts: 637
Re: take attribute and create hyperlink and attach to block
« Reply #9 on: April 13, 2012, 01:04:41 AM »
Lee, just.. WOW, that does all of them in a mass strike, that's amazing.
Does exactly what I was after only even better, I thankee.

Do you mind if I point people to this thread? I have a feeling a lot of folks would find this very useful.
feel free to use, copy, modify, update...
kruuger

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: take attribute and create hyperlink and attach to block
« Reply #10 on: April 13, 2012, 06:31:21 AM »
Lee, just.. WOW, that does all of them in a mass strike, that's amazing.

All credit to Kruuger  :-)

Drafter X

  • Swamp Rat
  • Posts: 578
Re: take attribute and create hyperlink and attach to block
« Reply #11 on: April 13, 2012, 07:00:19 AM »
Ah sorry, you name showed there in the code, I was rather blown away. Kruuger, you indeed rock, but most of the people here tend to rock.  8-)

CadJockey Militia Commander

kruuger

  • Swamp Rat
  • Posts: 637
Re: take attribute and create hyperlink and attach to block
« Reply #12 on: April 13, 2012, 07:34:11 AM »
Ah sorry, you name showed there in the code, I was rather blown away. Kruuger, you indeed rock, but most of the people here tend to rock.  8-)
happy to help  :-)
k.

Drafter X

  • Swamp Rat
  • Posts: 578
Re: take attribute and create hyperlink and attach to block
« Reply #13 on: April 13, 2012, 09:21:14 AM »
Shared it on my site with credit to Kruuger and the swamp.
http://www.brega-tech.com/?i=downloads
 8-)
CadJockey Militia Commander

krampaul82

  • Guest
Re: take attribute and create hyperlink and attach to block
« Reply #14 on: April 13, 2012, 03:02:39 PM »
Ah sorry, you name showed there in the code, I was rather blown away. Kruuger, you indeed rock, but most of the people here tend to rock.  8-)
Agreed :-D