Jump to content

Help me, Export dimension and number to excel


minhphuong_humg

Recommended Posts

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!

Edited by minhphuong_humg
Link to comment
Share on other sites

(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)

Link to comment
Share on other sites

(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)

 

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!

Link to comment
Share on other sites

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

 

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!

Link to comment
Share on other sites

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

 

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!

Link to comment
Share on other sites

(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)

Link to comment
Share on other sites

(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)

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!

Link to comment
Share on other sites

you just select one dimension and one text at once....if you select more that 2 object, program will show error

 

Thank Dipesh Kalasaria very much.

But, As I understand, it's not a much different approach (#2).

I mean:

Load lisp: td

select Dimension 1, Number1...contiunue Select Dimension 2, number 2,........., Finish (right mouse).

Export Excel.

 

And your lisp:

 

Select DM1, N1 -->right mouse

Select DM2, N2 -->right mouse

......

Finish.

repeat td to much.

Please, help me.

Thank you very much!

Good luck for you!

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...