attaching hyperlinks to object.

Discussion in 'AutoCAD' started by Nauman M, Jan 2, 2004.

  1. Nauman M

    Nauman M Guest

    I did a search but could not find my answer. I would appreciate if
    someone can show me how to attach a URL and the URLdescription to an
    MTEXT object, or any object as most all abjects have the hyperlink
    property. I am having some issues trying to do it via vlisp.
    thanks

    (setq obj (nm_ent2vla (entlast))
    (setq hyprlnkobj (vlax-get-property obj 'Hyperlinks))

    after that I cannot figure out how to add a URLdescription and the link.
    thanks
     
    Nauman M, Jan 2, 2004
    #1
  2. Nauman M

    Jeff Mishler Guest

    This should get you started:

    (defun setHype (/ obj hStr objLinks)
    (setq obj
    (vlax-ename->vla-object
    (car
    (entsel "\nSelect object to attach Hyperlink: ")))
    hStr (getstring t "\nEnter hyperlink: ")
    objLinks (vla-get-hyperlinks obj)
    )
    (vla-add objLinks hStr)
    )

    HTH,
    Jeff
     
    Jeff Mishler, Jan 2, 2004
    #2
  3. Nauman M

    Nauman M Guest

    thanks for your replies, check whether I am not doing something wrong.

    this is what I came up with
    (setq pathurl (strcat (getvar "dwgprefix") "keynotes.txt"))
    (setq mtextobj (nm_ent2vla (entlast))
    ;;get the reference to the Hyperlinks object
    (setq hyprlnkobj (vlax-get-property mtextobj 'Hyperlinks))
    ;now add the Hyperlink URL. if the count is 0 it will automatically
    create one
    (vlax-invoke-method hyprlnkobj 'Add.Hyperlinks pathurl)
    ;;get the first hyperlink object
    ; number of hyperlinks
    ;; (vlax-get-property hyprlnk 'Count)
    ;;since I am creating the object new, I dont have to worry about
    count being more than 0.
    ;get the first hyperlinkobject
    (setq hyprlink1 (vla-item hyprlnkobj 0))
    ;;now put the URLdescription in the
    (vlax-put-property hyprlink1 'URLDescription leadertext)

    ;;release the objects
    (mapcar 'vlax-release-object (list mtextobj hyprlnkobj
    hyprlink1))
     
    Nauman M, Jan 2, 2004
    #3
  4. Nauman M

    Murph Guest

    (setq newlink "MyURLlink")
    (setq ent (car (entsel)))
    (setq obj (vlax-ename->vla-object ent))
    (setq hy (vlax-get-property obj 'hyperlinks))
    (vlax-invoke-method hy 'Add newlink )

    This adds the URL needs some extra work to add the description.

    Murph
     
    Murph, Jan 2, 2004
    #4
  5. Nauman M

    Nauman M Guest

    see my post before yours.
     
    Nauman M, Jan 5, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.