minhphuong_humg 发表于 2022-7-5 18:15:25

Help me, Export dimension and

Hi, every body!
I have a drawing with dimensions and numbers.
Please help me a lisp Select Dimension and Number after export to Excel.
Thank you very much!

Dipesh Kalasari 发表于 2022-7-5 18:23:50

(defun c:td(/ D_VAL PRE T_VAL XLACELL XLAPP) (setq xlApp (vlax-get-object "Excel.Application")xlACell(vlax-get-property xlApp "ActiveCell")pre 0); SET YOUR DIMENSION VALUE PRECISION HERE (setq t_val(vla-get-textstring (vlax-ename->vla-object (car(entsel"\nPick text: ")))))   (vlax-put-property xlAcell "Value2" t_val) (setq d_val(rtos (vla-get-Measurement (vlax-ename->vla-object (car(entsel"\nPick dimension: ")))) 2 pre))       (vlax-put-property (vlax-get-property xlAcell "OFFSET" 0 1) "Value2" d_val) (vlax-invoke-method (vlax-get-property xlAcell "OFFSET" 1 0) "Activate")(vlax-release-object xlApp)(vlax-release-object xlAcell) (princ) )(vl-load-com)

minhphuong_humg 发表于 2022-7-5 18:29:22

 
Thank Dipesh Kalasaria very much!
But I run lisp is error.
Command: td
; error: bad argument type: VLA-OBJECT nil
Please, help me.
P/S:
You can edit help me Select by windows as Pick? Thank you.
Good luck for you!

Dipesh Kalasari 发表于 2022-7-5 18:37:15

start excel with new sheet and try again. this program will send text value and dimension value to excel

minhphuong_humg 发表于 2022-7-5 18:44:13

 
Thank Dipesh Kalasaria,
I'm try and ok.
But I have to repeat to much command "td".
Please, help me edit select by windows. Select (save temp), then finish export to excel.
Thank you very much!
Good luck for you!

Dipesh Kalasari 发表于 2022-7-5 18:51:22

All selection at once ? or Only one text and one dimension at once ?

minhphuong_humg 发表于 2022-7-5 18:56:16

 
I want Only one text and one dimension at once (save temp). After finish is export to Excel.
Please, help me.
Thank you very much!

Dipesh Kalasari 发表于 2022-7-5 19:03:15

(defun c:td(/ ENT1 ENT2 PRE SS XLACELL XLAPP)
(setq xlApp (vlax-get-object "Excel.Application")
        xlACell(vlax-get-property xlApp "ActiveCell")
        pre 0 ; SET YOUR DIMENSION VALUE PRECISION HERE
        ss(ssget '((-4 . "")))
        )
 
(if (> (sslength ss) 2)(progn(princ"\nMore than two object selected...")(princ)(exit)))
(setq ent1 (vlax-ename->vla-object (ssname ss 0))
        ent2 (vlax-ename->vla-object (ssname ss 1))
        )
 
(if (= (vla-get-objectname ent1) "AcDbText")
    (progn
      (vlax-put-property xlAcell "Value2" (vla-get-textstring ent1))
      (vlax-put-property (vlax-get-property xlAcell "OFFSET" 0 1) "Value2" (rtos (vla-get-Measurement ent2) 2 pre))
      )
    (progn
      (vlax-put-property xlAcell "Value2" (vla-get-textstring ent2))
      (vlax-put-property (vlax-get-property xlAcell "OFFSET" 0 1) "Value2" (rtos (vla-get-Measurement ent1) 2 pre))
      )
    )
 
(vlax-invoke-method (vlax-get-property xlAcell "OFFSET" 1 0) "Activate")
 
(vlax-release-object xlApp)(vlax-release-object xlAcell)
(princ)
)
(vl-load-com)

minhphuong_humg 发表于 2022-7-5 19:05:33

Dear, Dipesh Kalasaria
I run lisp is error.

Command: td
 
Select objects: 1 found
 
Select objects: 1 found, 2 total
 
Select objects: 1 found, 3 total
 
Select objects: 1 found, 4 total
 
Select objects:

 

More than two object selected...; error: quit / exit abort

First:
Open excel
Second:
Open file autocad, load lisp
CMD: td
select Dimension 1, number 1; select dimension 2, number 2.....
Finish.
 
Error...
Please, help me.
Good luck for you!

Dipesh Kalasari 发表于 2022-7-5 19:12:18

you just select one dimension and one text at once....if you select more that 2 object, program will show error
页: [1] 2
查看完整版本: Help me, Export dimension and