Author Topic: which code can change Tolerance Display to Basic  (Read 3200 times)

0 Members and 1 Guest are viewing this topic.

masao

  • Newt
  • Posts: 97
which code can change Tolerance Display to Basic
« on: October 21, 2023, 05:22:58 AM »
which code can change Tolerance Display to Basic,how to change to picture showing by lisp?

HOSNEYALAA

  • Newt
  • Posts: 107
Re: which code can change Tolerance Display to Basic
« Reply #1 on: October 21, 2023, 07:52:04 AM »
try

Code: [Select]
c#

(defun c:ccdtoleranceDisplay (/ DT ENT ID SDT)
  (setq dt  (ssget '((0 . "DIMENSION")))
        sdt (sslength dt)
        id  0

  ) ;_ end of setq
  (repeat sdt

    (progn
      (setq
        ent (ssname dt id)
        id  (1+ id)

      ) ;_ end of setq

      (vlax-put-property
        (vlax-ename->vla-object ent)
        'toleranceDisplay
        4
      ) ;_ end of vlax-put-property
    ) ;_ end of progn
  ) ;_ end of repeat
 
 
  (princ)
) ;_ end of defun
;;;;;;;;;;;;;;;;;;;;;;;;;;

masao

  • Newt
  • Posts: 97
Re: which code can change Tolerance Display to Basic
« Reply #2 on: October 22, 2023, 02:43:14 AM »
thank you very much.

i know how to change in cad,but i don't know how to change by lisp.

i can not find which code can change it.

thanks your teach,thank you very much.

BIGAL

  • Swamp Rat
  • Posts: 1434
  • 40 + years of using Autocad
Re: which code can change Tolerance Display to Basic
« Reply #3 on: October 22, 2023, 06:32:04 PM »
You can add the rest of code required.

Code: [Select]
(setq obj (vlax-ename->vla-object (car  (entsel "Pick dim to remove tolerance "))))
(vla-put-tolerancedisplay obj 0)
A man who never made a mistake never made anything

masao

  • Newt
  • Posts: 97
Re: which code can change Tolerance Display to Basic
« Reply #4 on: March 19, 2024, 08:25:06 AM »
How to get Basic+Deviation?

masao

  • Newt
  • Posts: 97
Re: which code can change Tolerance Display to Basic
« Reply #5 on: March 30, 2024, 03:21:32 AM »
if dimension Deviation how to get basic and keep Deviation?

Lee Mac

  • Seagull
  • Posts: 12928
  • London, England
Re: which code can change Tolerance Display to Basic
« Reply #6 on: March 31, 2024, 08:42:19 AM »
Unless I've misunderstood, something like this?

Code - Auto/Visual Lisp: [Select]
  1. (defun getdimtext ( ent / blk btr enx rtn )
  2.     (if (and (setq enx (entget ent))
  3.              (setq blk (cdr (assoc 2 enx)))
  4.              (setq btr (tblobjname "block" blk))
  5.         )
  6.         (while (and (setq btr (entnext btr)) (not rtn))
  7.             (if (= "MTEXT" (cdr (assoc 0 (setq enx (entget btr)))))
  8.                 (setq rtn (cdr (assoc 1 enx)))
  9.             )
  10.         )
  11.     )
  12.     rtn
  13. )

masao

  • Newt
  • Posts: 97
Re: which code can change Tolerance Display to Basic
« Reply #7 on: April 06, 2024, 06:58:08 AM »
Unless I've misunderstood, something like this?

Code - Auto/Visual Lisp: [Select]
  1. (defun getdimtext ( ent / blk btr enx rtn )
  2.     (if (and (setq enx (entget ent))
  3.              (setq blk (cdr (assoc 2 enx)))
  4.              (setq btr (tblobjname "block" blk))
  5.         )
  6.         (while (and (setq btr (entnext btr)) (not rtn))
  7.             (if (= "MTEXT" (cdr (assoc 0 (setq enx (entget btr)))))
  8.                 (setq rtn (cdr (assoc 1 enx)))
  9.             )
  10.         )
  11.     )
  12.     rtn
  13. )

i use code but not change just get princ "305,71±0,08"

i want to add dimension text box,dimension or text replacement dimension use HOSNEYALAA's code is ok.

but Deviation dimension can not keep Symmetrical tolerance.

i post picture is else lisp make it,but i don't know how to get it,or lisp can not do it?

ribarm

  • Gator
  • Posts: 3310
  • Marko Ribar, architect
Re: which code can change Tolerance Display to Basic
« Reply #8 on: April 06, 2024, 07:32:43 AM »
You mean something like this - look at picture and DWG... I just changed height of tolerances from 1.0 to 0.5...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

masao

  • Newt
  • Posts: 97
Re: which code can change Tolerance Display to Basic
« Reply #9 on: April 08, 2024, 08:38:25 AM »
You mean something like this - look at picture and DWG... I just changed height of tolerances from 1.0 to 0.5...

sorry,i use picture to express whit i mean.

thanks for your reply.

ribarm

  • Gator
  • Posts: 3310
  • Marko Ribar, architect
Re: which code can change Tolerance Display to Basic
« Reply #10 on: April 08, 2024, 09:15:10 AM »
You can add the rest of code required.

Code: [Select]
(setq obj (vlax-ename->vla-object (car  (entsel "Pick dim to remove tolerance "))))
(vla-put-tolerancedisplay obj 0)

Isn't this what you want... BIGAL already answered...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

masao

  • Newt
  • Posts: 97
Re: which code can change Tolerance Display to Basic
« Reply #11 on: April 08, 2024, 10:15:30 AM »
You can add the rest of code required.

Code: [Select]
(setq obj (vlax-ename->vla-object (car  (entsel "Pick dim to remove tolerance "))))
(vla-put-tolerancedisplay obj 0)

Isn't this what you want... BIGAL already answered...

i want chang to (vla-put-tolerancedisplay obj 4) and keep text box. like this picture.it is use autolist to make?or use VBA?

this picture is else lisp make it but i want to know how to make text box like basic(vla-put-tolerancedisplay obj 0).

i want to get add text box result.
« Last Edit: April 08, 2024, 10:23:26 AM by masao »

ribarm

  • Gator
  • Posts: 3310
  • Marko Ribar, architect
Re: which code can change Tolerance Display to Basic
« Reply #12 on: April 08, 2024, 02:33:53 PM »
To change dimstyle to one with text frame you have to change DXF 147 code from this example to negative value and to remove deviations you'll have to remove rest of MTEXT in DXF 1 code... Something like this example, but if you want to do this fast I don't see why not just using (MA) - matchprop like you described... Anyway, there is no system variable for frame like DIM* only DIMGAP - also negative for text frame...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:dimtolerances ( / *error* s i e o ox )
  2.  
  3.  
  4.   (defun *error* ( m )
  5.     (if m (prompt m))
  6.     (princ)
  7.   )
  8.  
  9.   (prompt "\nSelect DIMENSION entities...")
  10.   (setq s (ssget "_:L" (list (cons 0 "DIMENSION"))))
  11.   (repeat (setq i (sslength s))
  12.     (setq e (ssname s (setq i (1- i))))
  13.     (cond
  14.       ( (= (vla-get-tolerancedisplay (setq o (vlax-ename->vla-object e))) 0)
  15.         (vla-put-tolerancedisplay o 4)
  16.         (setq ox (entget (tblobjname "dimstyle" (cdr (assoc 3 (entget e)))) (list "*")))
  17.         (if (> (cdr (assoc 147 ox)) 0)
  18.           (entupd (cdr (assoc -1 (entmod (subst (cons 147 (- 0 (cdr (assoc 147 ox)))) (assoc 147 ox) ox)))))
  19.         )
  20.         (setvar (quote dimgap) (if (> (getvar (quote dimgap)) 0) (- 0 (getvar (quote dimgap))) (getvar (quote dimgap))))
  21.       )
  22.       ( (> (vla-get-tolerancedisplay o) 0)
  23.         (vla-put-tolerancedisplay o 0)
  24.         (setq ox (entget (tblobjname "dimstyle" (cdr (assoc 3 (entget e)))) (list "*")))
  25.         (if (< (cdr (assoc 147 ox)) 0)
  26.           (entupd (cdr (assoc -1 (entmod (subst (cons 147 (abs (cdr (assoc 147 ox)))) (assoc 147 ox) ox)))))
  27.         )
  28.         (setvar (quote dimgap) (if (< (getvar (quote dimgap)) 0) (abs (getvar (quote dimgap))) (getvar (quote dimgap))))
  29.       )
  30.     )
  31.     (entupd e)
  32.   )
  33.   (*error* nil)
  34. )
  35.  
« Last Edit: April 08, 2024, 07:25:13 PM by ribarm »
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

masao

  • Newt
  • Posts: 97
Re: which code can change Tolerance Display to Basic
« Reply #13 on: April 08, 2024, 07:17:55 PM »
To change dimstyle to one with text frame you have to change DXF 147 code from this example to negative value and to remove deviations you'll have to remove rest of MTEXT in DXF 1 code... Something like this example, but if you want to do this fast I don't see why not just using (MA) - matchprop like you described... Anyway, there is no system variable for frame like DIM*...

Code - Auto/Visual Lisp: [Select]
  1. (defun c:tt ( / *error* s i e o ox )
  2.  
  3.  
  4.   (defun *error* ( m )
  5.     (if m (prompt m))
  6.     (princ)
  7.   )
  8.  
  9.   (prompt "\nSelect DIMENSION entities...")
  10.   (setq s (ssget "_:L" (list (cons 0 "DIMENSION"))))
  11.   (repeat (setq i (sslength s))
  12.     (setq e (ssname s (setq i (1- i))))
  13.     (cond
  14.       ( (= (vla-get-tolerancedisplay (setq o (vlax-ename->vla-object e))) 0)
  15.         (vla-put-tolerancedisplay o 4)
  16.         (setq ox (entget (tblobjname "dimstyle" (cdr (assoc 3 (entget e)))) (list "*")))
  17.         (if (> (cdr (assoc 147 ox)) 0)
  18.           (entupd (cdr (assoc -1 (entmod (subst (cons 147 (- 0 (cdr (assoc 147 ox)))) (assoc 147 ox) ox)))))
  19.         )
  20.       )
  21.       ( (= (vla-get-tolerancedisplay o) 4)
  22.         (vla-put-tolerancedisplay o 0)
  23.         (setq ox (entget (tblobjname "dimstyle" (cdr (assoc 3 (entget e)))) (list "*")))
  24.         (if (< (cdr (assoc 147 ox)) 0)
  25.           (entupd (cdr (assoc -1 (entmod (subst (cons 147 (abs (cdr (assoc 147 ox)))) (assoc 147 ox) ox)))))
  26.         )
  27.       )
  28.     )
  29.     (entupd e)
  30.   )
  31.   (*error* nil)
  32. )
  33.  

thanks so much. i just want to know from (vla-put-tolerancedisplay obj 4) change to (vla-put-tolerancedisplay obj 4)+text box like (vla-put-tolerancedisplay obj 0) by autolisp ←it is possible?

other lisp can do if but can not see code ,so i don't know other lisp how to do it. or it is use other programming language.

ribarm

  • Gator
  • Posts: 3310
  • Marko Ribar, architect
Re: which code can change Tolerance Display to Basic
« Reply #14 on: April 08, 2024, 07:31:32 PM »
I've changed the code - see my latest revision in post above... ^^^^ It removes tolerances and toggles text frames... That's what you described in your firstly posted pictures... I hope that's what you initialy searched for...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube