Author Topic: Write from vlisp to excel file  (Read 14858 times)

0 Members and 1 Guest are viewing this topic.

Amsterdammed

  • Guest
Re: Write from vlisp to excel file
« Reply #15 on: November 01, 2005, 01:21:13 PM »
Thanks Mark :-)

DEVITG

  • Bull Frog
  • Posts: 479
Re: Write from vlisp to excel file
« Reply #16 on: November 06, 2005, 02:10:50 PM »
Hi Its not mine, I made some changes .
I have permission from author to spread it.
 



 
Code: [Select]
       (defun c:Excel ()
;;;; DESARROLLO DE PROGRAMAS PARA CONSTRUCCION-ALEJANDRO LEGUIZAMON- arquingeneu@gmail.com
  (vl-load-com)
  (setq *AplExcel*   (vlax-get-or-create-object "excel.application")
*ColeccionLibros* (vlax-get-property *AplExcel* "Workbooks")
*NuevoLibro*   (vlax-invoke-method *ColeccionLibros* "add")
*ColeccionHojas*  (vlax-get-property *NuevoLibro* "Sheets")
*Hoja1*   (vlax-get-property *ColeccionHojas* "Item" 1)
*CeldasExcel*   (vlax-get-property *Hoja1* "Cells")
  )
  (vla-put-visible *AplExcel* :vlax-true)
  (setq fila 3)
  (setq n 0)
  (setq seleccion (ssget))
  (setq cantidad (sslength seleccion))
  (repeat cantidad
    (setq nombre (ssname seleccion n))


    ;;  (setq valor (vlax-curve-getArea nombre))
    (setq fin (vlax-curve-getendparam nombre))
    (setq principio (vlax-curve-getStartParam nombre))
    (setq pto-fin (vlax-curve-getEndPoint nombre))
    (setq longitud (vlax-curve-getDistAtPoint nombre pto-fin))
    (setq valor longitud)
    (vlax-put-property
      *CeldasExcel*
      "Item"
      fila
      2
      (vl-princ-to-string valor)
    )
    (setq lista (entget nombre))
    (SETQ capa (CDR (ASSOC 8 lista)))
    (SETQ punto (ASSOC 10 lista))
    (setq x (cadr punto))
    (setq y (caddr punto))
    ;;(command "_zoom" "c" (list x y) "5")
    (vlax-put-property
      *CeldasExcel*
      "Item"
      fila
      1
      (vl-princ-to-string capa)
    )
    ;;(setq t1 "Ingresa Altura ò Peralte de ")
  ;(setq tt (strcat t1 capa ))
  ;(print tt)
  ;(setq H (getreal))
  ;(vlax-put-property *CeldasExcel* "Item" fila 3
  ;(vl-princ-to-string H))
  ;(setq volumen (* valor H))
  ;(vlax-put-property *CeldasExcel* "Item" fila 4
  ;(vl-princ-to-string volumen))
    (setq n (+ n 1))
    (setq fila (+ fila 1))
  )
  (vlax-put-property
    *CeldasExcel*
    "Item"
    1
    1
    (vl-princ-to-string
      "Rutina Autolisp para calculo de longitud - ALEJANDRO LEGUIZAMON -  http://arquingen.tripod.com.co--modif por DEVITG"
    )
  )
  (vlax-put-property
    *CeldasExcel*
    "Item"
    2
    1
    (vl-princ-to-string "capa")
  )
  (vlax-put-property
    *CeldasExcel*
    "Item"
    2
    2
    (vl-princ-to-string "Longitud")
  )
  ;(vlax-put-property *CeldasExcel* "Item" 2 3
  ;(vl-princ-to-string "Altura"))
  ;(vlax-put-property *CeldasExcel* "Item" 2 4
  ;(vl-princ-to-string "volumen"))
  (vlax-release-object *CeldasExcel*)
  (vlax-release-object *Hoja1*)
  (vlax-release-object *ColeccionHojas*)
  (vlax-release-object *NuevoLibro*)
  (vlax-release-object *ColeccionLibros*)
  (vlax-release-object *AplExcel*)
)

(c:excel)
;|«Visual LISP© Format Options»
(72 2 50 2 nil "end of " 60 9 0 0 0 T T nil T)
;*** DO NOT add text below the comment! ***|;
Location @ Córdoba Argentina Using ACAD 2019  at Window 10