I have a drawing with dimensions and number (number and text number). I want ouput (Can select or Automatic) to a file excel. Please, write a lisp do.
Thank you very much.
I want ouput to excel the same this picture.
@minhphuong.humg wrote:
I have a drawing with dimensions and number (number and text number). I want ouput (Can select or Automatic) to a file excel. Please, write a lisp do.
Thank you very much.
...
minhphuong.humg,
this quick and dirty code will create a .csv file, in the dwg directory with the same name, try it, is minimally tested...
(defun c:test (/ *error* a b c file line) (defun *error* (msg) (if file (close file) ) (vl-cmdf "regen") (cond ((not msg)) ((member msg '("Function cancelled" "quit / exit abort"))) ((princ (strcat "\n** Error: " msg " ** "))) );; cond (princ) );; *error* (setq file (open (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".csv" ) "w" ) ) (while (and (not (prompt "\n<<< Select the number >>>")) (setq a (ssget "_+.:E:S" '((0 . "TEXT")))) (not (redraw (ssname a 0) 3)) (not (prompt "\n<<< Select the reference >>>")) (setq b (ssget "_+.:E:S" '((0 . "TEXT")))) (not (redraw (ssname b 0) 3)) (not (prompt "\n<<< Select the length >>>")) (setq c (ssget "_+.:E:S" '((0 . "TEXT")))) (not (redraw (ssname c 0) 3)) );; and (setq line (strcat (cdr (assoc 1 (entget (ssname a 0)))) "\t" (cdr (assoc 1 (entget (ssname b 0)))) "\t" (cdr (assoc 1 (entget (ssname c 0)))) ) ) (write-line line file) );; while (close file) (*error* nil) (princ) );; test
HTH
Henrique
Hi Enrique at
(not (prompt "\n<<< Select the length >>>")) (setq c (ssget "_+.:E:S" '((0 . "TEXT"))))
The lenght is not a TEXT , it is a Aligned Dimension.
@devitg wrote:
Hi Enrique at
(not (prompt "\n<<< Select the length >>>")) (setq c (ssget "_+.:E:S" '((0 . "TEXT"))))
The lenght is not a TEXT , it is a Aligned Dimension.
Gabriel,
thanks, you are correct, I was with an open dwg posted by Patcy at
when the same OP start this thread, so I thought that was the same dwg, my bad...
So here's the revised code:
(defun c:test (/ *error* a b c file line) (defun *error* (msg) (if file (close file) ) (vl-cmdf "regen") (cond ((not msg)) ((member msg '("Function cancelled" "quit / exit abort"))) ((princ (strcat "\n** Error: " msg " ** "))) );; cond (princ) );; *error* (setq file (open (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".csv" ) "w" ) ) (while (and (not (prompt "\n<<< Select the number >>>")) (setq a (ssget "_+.:E:S" '((0 . "TEXT")))) (not (redraw (ssname a 0) 3)) (not (prompt "\n<<< Select the reference >>>")) (setq b (ssget "_+.:E:S" '((0 . "TEXT")))) (not (redraw (ssname b 0) 3)) (not (prompt "\n<<< Select the length >>>")) (setq c (ssget "_+.:E:S" '((0 . "DIMENSION")))) (not (redraw (ssname c 0) 3)) );; and (setq line (strcat (cdr (assoc 1 (entget (ssname a 0)))) "\t" (cdr (assoc 1 (entget (ssname b 0)))) "\t" (rtos (cdr (assoc 42 (entget (ssname c 0)))) 2 0) ) ) (write-line line file) );; while (close file) (*error* nil) (princ) );; test
Henrique
I think the csv file should open on 'append' mode than 'write' mode.
Hence OP can continue selection and csv file gets updated.
(setq file (open (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".csv" ) "a" ) )
Find attached a FAS file , and the CSV .
You only need to pick at any DIM , and then at any REF or NUM
@Ajilal.Vijayan wrote:
I think the csv file should open on 'append' mode than 'write' mode.
Hence OP can continue selection and csv file gets updated.
(setq file (open (strcat (getvar "dwgprefix") (vl-filename-base (getvar "dwgname")) ".csv" ) "a" ) )
Agree!
It's a good idea using the "append" insted of "write", we can also give OP the chance to choose the output file name, and... but it is just a demo, let's wait the OP feedback.
Henrique
Nice one, Gabriel!
Using EXpressTools functions, you have to be sure that the OP have ET installed, however, it's a pity that don't share your code with us...
Henrique
@devitg wrote:
Hi Enrique, no EXpressTools used.
Just vl-lisp
Gabriel,
from your code:
Command: (LOAD "C:/a-test/a-test/GabrielEnrique/dim-text-tocsv.fas")
Put
TXT-TO-CSV
at the command linenil
Command: TXT-TO-CSV
acetutil.arx esta cargado
_
Pick one dimension:
Select objects:
Henrique
Thank my friends (hmsilva, devitg, ajilal.vijayan). Special, lisp's devitg very very good with the simplest case (my drawing upload). However, I must do work very hard. It's complexer than you think.
With drawings (attach) complex I must pick each object from autocad to excel. Very long with drawing complex.
My friends, please help me write lisp (can select dimension (pick), select other text (select window or pick)) to output as image attach. Mr. hmsilva, devitg, ajilal.vijayan please help me!
Really, thank my friends very much.
P/S: Can you give me solutions that work fast to have results like that?
The attached drawing looks 'complex'
As you wait for the lisp routine in here,
Can I suggest something that will make your work more easier in future ?
I think you should start creating Dynamic block with attributes for this kind of job.
So for an external output you can use DATAEXRACTION command.
Forma parte de una defun básica
It is par of a basic DEFUN
(IF (= (CAR (MEMBER "acetutil.arx" (ARX))) "acetutil.arx") (PRINC (STRCAT "acetutil.arx" " esta cargado")) (PROGN (ARXLOAD "acetutil.arx" "no se cargo") (PRINC (STRCAT "acetutil.arx" "..se ha cargado")) ) )
No tiene implicancias en el lisp
It have no implied action on the LISP
Dir, ajilal.vijayan. I do not understand your health. I think, there are things I know I've said things. Here I ask is I want to help people. I would help you or others in a field that I knew. Simply as that. I think, could not create such block. Thank you very much.
As ever and for the last of the times to being , The OP, only show a part of it .
It is like to go to the Surgeon Officce, show the arm and hand , and ask for a help to heal its leg .
Why it will be it so???
Mr minhphuong.humg, you ask for help , and offer yours knows.
What can you offer?
@devitg wrote:
Forma parte de una defun básica
It is par of a basic DEFUN
(IF (= (CAR (MEMBER "acetutil.arx" (ARX))) "acetutil.arx") (PRINC (STRCAT "acetutil.arx" " esta cargado")) (PROGN (ARXLOAD "acetutil.arx" "no se cargo") (PRINC (STRCAT "acetutil.arx" "..se ha cargado")) ) )No tiene implicancias en el lisp
It have no implied action on the LISP
Gabriel,
only commented the command line echo...
Henrique
minhphuong.humg,
it is a good practice, when asking for help, provide the maximum of information possible, to ensure that the person who try to helps us, is not wasting time...
First - we all, are using our free time to help other people who have more difficulties than we!
Second - you should consider the ajilal.vijayan advice as a good practice for future jobs like this, using Dynablocks, Attributes and the DATAEXRACTION command, the excel spreadsheet would be automatically created!
Third - let's see what we can get, working together, if you are interested...
Starting, at your "complex.dwg" and at the image you attached, there are some coffers with no name, this is a possible situation, or is just a failure?
Henrique
Dear, all my friends.
I think have a solution (ideas):
First: select dimension 1, select (Pick) other texts (group text 1) (1, H8.5, 2H1, H4...)---->row 1
Then: right click (purpose to split into two lines in excel)
Second: Continue select dimension 2, select (pick) group text 2 (2, H6,5)---->row 2.
......
Just like that, Every time we select a group of them in a row in excel and finish (another line) by pressing the right mouse button.
End: double click (2 enter).
I hope to receive feedback and comments.
Please, you help me write a lisp work it. Only just like that is okay. I think so. That could solve my problem.
Thank all you very much!
Please.