Jump to content

how can I export the dimensions out into a file?


goofygirl72

Recommended Posts

I am trying to find away to export all the dimension out of a drawing to files so I can show a total of leghts. Is there away I can do this?

Link to comment
Share on other sites

The answer is yes, but you need to be a lot more detailed about what you are attempting to do.

Only selected dims?

All dims?

Dims on a certain layer?

What type of file to export to?

Do you know how to code in lisp?

Do you want someone to write this for you?

Link to comment
Share on other sites

Johnm

I need dims on a certain layer.

export to cvs or excel

have worked with lisp but not that good.

thank you for your reply

Link to comment
Share on other sites

fuccaro

I tried your dex lisp and I get ; error: bad argument type: streamp nil

I am not the good at lisp to know what causing this.

Link to comment
Share on other sites

Now is a good time to learn more. Crank up your lisp editor and dive in.

I will not write it for you but will help.

Here is an outline of some of the functions that you will need

(ssget "_X" '((0 . "DIMENSION")(8 . "the layer you need")(410 . "Model")))with a filter for dimensions and the layer

(sslength)

(ssname)

(while)

(strcat)

(open)

(write-line)

(close)

basically you need to:

get only dimensions on a particular layer using ssget

get the number of items in the ssget selection set using sslength

set up a while loop to go through the items and parse out the dimension text

create a list of the dim text and add a (,) between them to create a csv style

when the loop is finished open a file to write the list to

write the list to the file

close the file.

If you decide to do this your self this would be a good lips to learn from

Link to comment
Share on other sites

Quick one,

 

(defun c:DimExport (/ i ss file e)

 (if (and (setq i -1 ss (ssget '((0 . "DIMENSION"))))
          (setq file (getfiled "Output" "" "txt;csv" 1)))
   (progn
     (setq file (open file "w"))
     (while (setq e (ssname ss (setq i (1+ i))))
       (write-line (rtos (cdr (assoc 42 (entget e)))) file))
     (close file)))

 (princ))

Bear in mind Angular Dims will export in Radians :)

 

Sincere Apologies John - I didn't realise you had posted.

Link to comment
Share on other sites

No problem lee mac I just like to see more people learn to fish for themselves. I also have a hard time passing up a quicky

Link to comment
Share on other sites

fuccaro

I tried your dex lisp and I get ; error: bad argument type: streamp nil

I am not the good at lisp to know what causing this.

After years I tried it again and it worked in AutoCAD 2006. You entered in the program text the path to the file, didn't you?

Nevermind, I see in the mean time you get help.

Link to comment
Share on other sites

Give this a try:

 

(defun c:DimExport (/ i ss file e d)
 ;; Lee Mac  ~  08.04.10

 (if (and (setq i -1 ss (ssget '((0 . "DIMENSION"))))
          (setq file (getfiled "Output" "" "txt;csv" 1)))
   (progn
     (setq file (open file "w"))
     (while (setq e (ssname ss (setq i (1+ i))))
       (setq d (cdr (assoc 42 (entget e))))

       (write-line
         (if (or (= 2 (logand 2 (cdr (assoc 70 (entget e)))))
                 (= 5 (logand 5 (cdr (assoc 70 (entget e))))))
           (angtos d (getvar 'DIMAUNIT) (if (minusp (getvar 'DIMADEC))
                                          (getvar 'DIMDEC)
                                          (getvar 'DIMADEC)))
           
           (rtos d (getvar 'DIMLUNIT) (getvar 'DIMDEC))) file))
         
     (close file)))

 (princ))

  • Thanks 1
Link to comment
Share on other sites

Thank you all so much this will help and will save so much time listing over 5000 dimensions.

 

Thank you again

Goofygirl72

Link to comment
Share on other sites

  • 12 years later...
On 4/8/2010 at 7:02 AM, Lee Mac said:

Give this a try:

 

 

(defun c:DimExport (/ i ss file e d)
 ;; Lee Mac  ~  08.04.10

 (if (and (setq i -1 ss (ssget '((0 . "DIMENSION"))))
          (setq file (getfiled "Output" "" "txt;csv" 1)))
   (progn
     (setq file (open file "w"))
     (while (setq e (ssname ss (setq i (1+ i))))
       (setq d (cdr (assoc 42 (entget e))))

       (write-line
         (if (or (= 2 (logand 2 (cdr (assoc 70 (entget e)))))
                 (= 5 (logand 5 (cdr (assoc 70 (entget e))))))
           (angtos d (getvar 'DIMAUNIT) (if (minusp (getvar 'DIMADEC))
                                          (getvar 'DIMDEC)
                                          (getvar 'DIMADEC)))
           
           (rtos d (getvar 'DIMLUNIT) (getvar 'DIMDEC))) file))
         
     (close file)))

 (princ))
 

 

Hi Lee Mac, 
I was looking for a lisp like this. On my job I have to set different suffix/prefix or codes by overriding or addin text into the dimensions. So, I have a couple 

of questions:
1. Is tehere a way to also obtain the prefix and sufix of the selected dimensions? 
2. Is it possible to get the overrided dimensions/text? 


thanks in advance!
 

 1183573266_overriddeninformation.thumb.png.7f26960f618b27a0b69a22e378ec887d.png1555014661_dimsuffix.thumb.png.e7822b054317f8083fdadba40cf21868.png1524455991_realvalueplusdata.thumb.png.2dc872cd41c2ff738b0721feec6936b7.png

Link to comment
Share on other sites

Setup a template drawing and and save dimension styles. You can use his steal function to copy the style into a new drawing with this.

 

(defun C:DStyle ()
  (Steal "C:\\path\\to\\drawing\\that\\has\\dims.dwg" '(( "Dimension Styles" ("Dim Name"))))
  (princ)
)

 

--edit

textoverride isn't part of the dimstyles and would need to be inputted for each dimension. I would also suggest to use a prefix to show that its an overridden dimension.

 

* or [ORD]

 

8'0" - no idea text is overridden

*8-'0"

[ORD] 8-'0"

* 8-'0" *

 

 

Edited by mhupp
  • Like 1
Link to comment
Share on other sites

Try this and look at code ( 1. xxx)   (entget (car (entsel "\nPick dim")))

 

You will see the <> in the dxf group (1 . this means use the value based on the dim points, if you fully overide the <> will not be there. You can see that in your dim string for the 3rd example. So pre<> is a prefix <>suf is a suffix. Yes could do a look into the dim text string and work out what type it is.

 

So when you say can you GET what you want, what to do with result make a file, make a table etc  ?

 

Edited by BIGAL
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...