Jump to content

How to add hyperlinks to the csv file


handasa

Recommended Posts

Greetings every one :

this lisp was developed by Mr.Tharwat somewhere in this website

 

(defun c:Test (/ s f o)
 ;; Tharwat 26. 08. 2015 ;
 (princ "\nSelect LWpolylines to export to Excel file :")
 (if (and (setq s (ssget '((0 . "LWPOLYLINE"))))
          (setq f (getfiled "Specify File Name" (getvar 'DWGPREFIX) "csv" 1))
          (setq o (open f "w"))
          )
   (progn
     ((lambda (r / e)
        (while (setq e (ssname s (setq r (1+ r))))
          (write-line (rtos (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) 2 4) o)
          ))
       -1)
     (close o)
     )
   )           
 (princ)
)

 

 

 

how can i add heperlinks of selected polylines to the exported csv file so that the exported files looks like as follow

 

qye5Y.jpg

 

 

thanks in advance :roll:

Link to comment
Share on other sites

Hi,

Try this [uNTESTED] mods on the codes and let me know:

 

(defun c:Test (/ s f o)
 ;; Tharwat 28. 08. 2016 ;
 (princ "\nSelect LWpolylines to export to Excel file :")
 (if (and (setq s (ssget '((0 . "LWPOLYLINE"))))
          (setq f (getfiled "Specify File Name" (getvar 'DWGPREFIX) "csv" 1))
          (setq o (open f "w"))
          )
   (progn
     (write-line "Polyline Length;Polyline Hyperlink" o)
     ((lambda (r / e l d ur)
        (while (setq e (ssname s (setq r (1+ r))))
          (vlax-for hp (vla-get-hyperlinks (vlax-ename->vla-object e))
            (if (setq ur (vla-get-url hp))
              ur)
            )
          (write-line (strcat (rtos (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) 2 4)
		       ";" (if ur ur "")) o)
   ))
-1)
     (close o)
     )
   )           
 (princ)
)(vl-load-com)

Edited by Tharwat
Link to comment
Share on other sites

another lisp written by you (mr.tharwat) that i tried and added part that extract the hyperlinks and lengths to the table

 

thanks mr.tharwat for your lisps and efforts

 

(defun c:ltt (/ pt2 pt3 s x y doc objtable numrows rowheight pt1 colwidth curspace)
;; Tharwat 26. 08. 2015 ;
;; mods by BIGAL 29.08.2015 now as table

(vl-load-com)
(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(setq curspace (vla-get-modelspace doc))
(setq pt1 (vlax-3d-point (getpoint "\nPick point for top left hand of table:  "))) 
;(princ "\nSelect LWpolylines to export to a Table :")

(setq pt2 (getpoint "Select by fence-line 1st set of entities : "))
 (setq pt3 (getpoint pt2 "2nd point of fence-line: ")
       s (ssget "F" (list pt2 pt3))
 ) ;_ end of setq
 
;(setq s (ssget '((0 . "LWPOLYLINE"))))

(if (/= s nil)
   (progn
 ; now do table 
   (setq numrows (+ 2 (sslength s)))
   (setq numcolumns 3)
   (setq rowheight 7)
   (setq colwidth 25)
   (setq objtable (vla-addtable curspace pt1 numrows numcolumns rowheight colwidth))
   (vla-settext objtable 0 0 "Pline lengths")
   (vla-setcolumnwidth objtable 0 10)
   (vla-setcolumnwidth objtable 1 25)
   (vla-settext objtable 1 0 "Pline") 
   (vla-settext objtable 1 1 "Length") 
(vla-settext objtable 1 2 "hyperlinks") 
   (vla-SetTextHeight Objtable (+ acDataRow acHeaderRow acTitleRow) 2.5)
   (vla-SetAlignment Objtable acDataRow acMiddleCenter)

   (setq x 1)
   (SETQ Y 2)
   (setq r -1)
   ;((lambda (r / e)

        (while (setq e (vlax-ename->vla-object(ssname s (setq r (1+ r)))))
        (vla-settext objtable Y 0 (rtos x 2 0))        
        (vla-settext objtable Y 1 (rtos  (vla-get-length e)  2 4))
	 (setq hypers (vlax-get-property e 'Hyperlinks))
	 (vla-settext objtable Y 2 (vlax-get-property (vla-item hypers 0) 'URL))
	  ;(setq vlaObj (vlax-ename->vla-object en))
	 ;(setq hypers (vlax-get-property e 'Hyperlinks))
        (setq x (1+ x ))
        (setq y (1+ Y ))
 ); while
    ; )) ;lambda
     )   ;progn
   (alert "You have not picked any plines run again")
   )     ; if      
 (princ)

) ; defun

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...