Dimension Export with tolerance

Dimension Export with tolerance

Boopathi_Sivakumar
Collaborator Collaborator
1,442 Views
9 Replies
Message 1 of 10

Dimension Export with tolerance

Boopathi_Sivakumar
Collaborator
Collaborator

Hello all,

Here is the attached LISP which is used to export all the dimensions in the drawing it is exporting as expected but is it possible to export the tolerance value with the dimension also.

please help me with this LISP

123.JPG

 

Thanks,

Boopathi

Boopathi Sivakumar
Sr Application Engineer
www.usamcadsoft.in
Facebook | Twitter | LinkedIn

0 Likes
1,443 Views
9 Replies
Replies (9)
Message 2 of 10

dbhunia
Advisor
Advisor

check...

 

DIMTP  & DIMTM (System Variable) 

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 3 of 10

Boopathi_Sivakumar
Collaborator
Collaborator

Thanks for your reply,

dimtp and dimtm is used to change the default tolerance value. if you see the attached lisp when you run the lisp it is exporting the all the dimensions in the drawing to excel but it only exports the dimensional values it is not exporting the tolerance values  so how i can add the tolerance values to the dimensions

 

Regards,

Boopathi

Boopathi Sivakumar
Sr Application Engineer
www.usamcadsoft.in
Facebook | Twitter | LinkedIn

0 Likes
Message 4 of 10

dbhunia
Advisor
Advisor

check THIS

 

 


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 5 of 10

Moshe-A
Mentor
Mentor

@Boopathi_Sivakumar  hi,

 

check this...note that the each dimension now writes to csv 3 numbers, first the dimension Measurement, second toleranceUpperLimit, third toleranceLowerLimit

 

enjoy

moshe

 

 

 

(defun c:DimExp ( / evaluate_dimensions ; local function
		    _DIMEXPDELIMITER ss lst fname file)

 (defun evaluate_dimensions (ename / AcDbDimension Measurement tolUL tolLL toldis result)
  (setq AcDbDimension (vlax-ename->vla-object ename))
  (setq Measurement (vla-get-measurement    AcDbDimension))
  (setq tolUL  (vla-get-toleranceUpperLimit AcDbDimension))
  (setq tolLL  (vla-get-toleranceLowerLimit AcDbDimension))
  (setq toldis (vla-get-toleranceDisplay    AcDbDimension)) 

  (setq result (cond
                ((or (= toldis acTolNone) (= toldis acTolBasic))
                 (cons Measurement (list 0.0 0.0))
                );case
                (t ; acTolSymmetrical or acTolDeviation or acTolLimits
                 (cons Measurement (list tolUL tolLL))   
                ); case
               ); cond
  ); setq 
  
  (vlax-release-object AcDbDimension)
  result
 ); evaluate_dimensions


 ; here starts c:dimexp
 (setq _DIMEXPDELIMITER ",") ; set to "," for CSY/DEU...
  
 (if (setq ss (ssget "_X" (list '(0 . "DIMENSION"))))
  (progn
   (setq lst (mapcar
               '(lambda (ename)
                 (evaluate_dimensions ename)
                ); lambda	
              (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
             ); mapcar
   ); setq
     
   (if lst
    (progn
     (setq fname (strcat (getvar "dwgprefix") "DimExp.csv"))
     (setq file (open fname "a")) ; append
     (write-line "" file)
     (princ (strcat (getvar "dwgname") _DIMEXPDELIMITER) file)
  
     (foreach item lst
      (foreach x item
       (princ x file)
       (princ _DIMEXPDELIMITER file)
      ); foreach
     ); foreach
  
     (if file (close file))
     (princ (strcat "\n" (itoa (length lst)) " dimensions written to " fname)) 
    ); progn
   ); if
   
  ); progn
 ); if
   
 (princ)
)
  

 

 

Message 6 of 10

Moshe-A
Mentor
Mentor

@Boopathi_Sivakumar 

 

made some fine tuning corrections.

 

(defun c:DimExp ( / evaluate_dimensions ; local function
		    _DIMEXPDELIMITER ss lst fname file i)

 (defun evaluate_dimensions (ename / AcDbDimension Measurement  tolUpL tolLoL tolDiS)
  (setq AcDbDimension (vlax-ename->vla-object ename)) ; allocating memory
   
  (setq Measurement   (vla-get-measurement AcDbDimension))
  (setq tolUpL (vla-get-toleranceUpperLimit AcDbDimension))
  (setq tolLoL (vla-get-toleranceLowerLimit AcDbDimension))
  (setq tolDiS (vla-get-toleranceDisplay    AcDbDimension))
   
  (vlax-release-object AcDbDimension); dispose memory

  (cons
    Measurement
     (cond
      ((or (= tolDiS acTolNone) (= tolDiS acTolBasic))
       (list 0.0 0.0)
      );case
      (t ; acTolSymmetrical or acTolDeviation or acTolLimits
       (list tolUpL tolLoL)   
      ); case
     ); cond
  ); cons
 ); evaluate_dimensions


 ; here starts c:dimexp
 (setq _DIMEXPDELIMITER ",") ; const
  
 (if (and
       (setq ss (ssget "_X" (list '(0 . "DIMENSION"))))
       (setq lst (mapcar
                  '(lambda (ename)
                    (evaluate_dimensions ename)
                   ); lambda	
                  (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
                 ); mapcar
       ); setq
     ); and
  (progn
   (setq fname (strcat (getvar "dwgprefix") "DimExp.csv"))
   (setq file (open fname "a")) ; append
   (write-line "" file)
   (princ (strcat (getvar "dwgname") _DIMEXPDELIMITER) file)

   (setq i 0)
   (foreach item lst
    (foreach x item
     (princ x file)
     (if (< (setq i (1+ i)) (* (length item) (length lst)))	
      (princ _DIMEXPDELIMITER file)
     )
    ); foreach
   ); foreach
  
   (if file (close file))
   (princ (strcat "\n" (itoa (length lst)) " dimensions written to " fname)) 
  ); progn
 ); if
   
 (princ)
); c:DimExp
  
Message 7 of 10

Boopathi_Sivakumar
Collaborator
Collaborator

@Moshe-A  Thanks for your help.

 

The Values getting it in columns can by any mean converted to rows?

 

Regards,

Boopathi

Boopathi Sivakumar
Sr Application Engineer
www.usamcadsoft.in
Facebook | Twitter | LinkedIn

0 Likes
Message 8 of 10

Moshe-A
Mentor
Mentor

do you mean writing each dimension on separate line?

0 Likes
Message 9 of 10

Boopathi_Sivakumar
Collaborator
Collaborator

Yes That's Right

 

Thanks,
Boopathi

Boopathi Sivakumar
Sr Application Engineer
www.usamcadsoft.in
Facebook | Twitter | LinkedIn

0 Likes
Message 10 of 10

dbhunia
Advisor
Advisor

Try with this some modifications in @Moshe-A  code (All credit goes to @Moshe-A )

 

(defun c:DimExp ( / evaluate_dimensions ; local function
		    ss lst fname file i Cont)

 (defun evaluate_dimensions (ename / AcDbDimension Measurement  tolUpL tolLoL tolDiS)
  (setq AcDbDimension (vlax-ename->vla-object ename)) ; allocating memory
   
  (setq Measurement   (vla-get-measurement AcDbDimension))
  (setq tolUpL (vla-get-toleranceUpperLimit AcDbDimension))
  (setq tolLoL (vla-get-toleranceLowerLimit AcDbDimension))
  (setq tolDiS (vla-get-toleranceDisplay    AcDbDimension))
   
  (vlax-release-object AcDbDimension); dispose memory

  (cons
    Measurement
     (cond
      ((or (= tolDiS acTolNone) (= tolDiS acTolBasic))
       (list 0.0 0.0)
      );case
      (t ; acTolSymmetrical or acTolDeviation or acTolLimits
       (list tolUpL tolLoL)   
      ); case
     ); cond
  ); cons
 ); evaluate_dimensions

 (defun DPlace (No / Dim Val)
  (setq Dim (getvar "DIMZIN"))
  (setvar "DIMZIN" 11)
  (setq Val (if (= No (fix No)) 0 (- (strlen (rtos No 2 8)) (+ (strlen (itoa (fix No))) 1))))
  (setvar "DIMZIN" Dim)
  Val
 )

 ; here starts c:dimexp
  
 (if (and
       (setq ss (ssget "_X" (list '(0 . "DIMENSION"))))
       (setq lst (mapcar
                  '(lambda (ename)
                    (evaluate_dimensions ename)
                   ); lambda	
                  (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
                 ); mapcar
       ); setq
     ); and
  (progn
   (setq fname (strcat (getvar "dwgprefix") "DimExp.csv"))
   (setq file (open fname "a")) ; append
   (write-line "" file)
   (setq Cont (getvar "dwgname"))

   (foreach item lst
    (foreach x item
     (setq Cont (strcat Cont "," (rtos x 2 (DPLACE x))))
    ); foreach
    (write-line Cont file)
    (setq Cont " ")
   ); foreach
  
   (if file (close file))
   (princ (strcat "\n" (itoa (length lst)) " dimensions written to " fname)) 
  ); progn
 ); if
 (princ)
)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes