Jump to content

Recommended Posts

Posted

I have a routine that takes a numeric string, does the math, and inserts a "bottom and top of curb elevation" attributed block into the drawing.

 

Zero Suppression is ON in my dimvars.

 

Due to how RTOS acts with DIMZIN, it will leave the zeros off even number elevations, and that's no good.

 

So I tried this:

(setq DZ (getvar "DIMZIN"))

(setvar "dimzin" 1) - turning suppression off

then at the end of the routine:

(setvar "dimzin" DZ)

 

Pretty normal SETVAR handeling. Right?

Wrong.

 

When the routine first ran, DIMZIN was 8.

After, it was 9. In my testing, it was 12 at one point. It might have to do with 'over rides', the annoying little things that they are.....

Now, when I reset it to 'on' via the Dim dialog box, it does not stay on.

I just saved and reopened the dwg. Dim dia shows suppression box not checked. Turn it on. OK out. Go back in. Box NOT checked. Turn it on, OK out.

Place dim, even number. Suppression IS working, but box not checked.

Check dimzin - set to 9.

What In The World is going on?!?

Is there a better way to deal with this RTOS vs DIMZIN thing?!?

 

Thanks guys,

Jeff

Posted

How about a 'custom rtos' :D

 

[color=RED]([/color][color=BLUE]defun[/color] LM:rtos [color=RED]([/color] real prec [color=RED])[/color] [color=RED]([/color][color=BLUE]vl-load-com[/color][color=RED])[/color]
 [color=#990099];; © Lee Mac 2011[/color]
 [color=RED]([/color]
   [color=RED]([/color][color=BLUE]lambda[/color] [color=RED]([/color] l [color=RED])[/color]
     [color=RED]([/color][color=BLUE]repeat[/color] [color=RED]([/color][color=BLUE]-[/color] prec [color=RED]([/color][color=BLUE]cond[/color] [color=RED]([/color] [color=RED]([/color][color=BLUE]vl-position[/color] [color=#009900]46[/color] l[color=RED])[/color] [color=RED])[/color] [color=RED]([/color] [color=RED]([/color][color=BLUE]setq[/color] l [color=RED]([/color][color=BLUE]cons[/color] [color=#009900]46[/color] l[color=RED]))[/color] [color=#009900]0[/color] [color=RED])))[/color]
       [color=RED]([/color][color=BLUE]setq[/color] l [color=RED]([/color][color=BLUE]cons[/color] [color=#009900]48[/color] l[color=RED]))[/color]
     [color=RED])[/color]
     [color=RED]([/color][color=BLUE]vl-string-right-trim[/color] [color=#a52a2a]"."[/color]
       [color=RED]([/color][color=BLUE]vl-list->string[/color]
         [color=RED]([/color][color=BLUE]cond[/color]
           [color=RED]([/color] [color=RED]([/color][color=BLUE]=[/color] [color=#009900]46[/color] [color=RED]([/color][color=BLUE]car[/color] [color=RED]([/color][color=BLUE]setq[/color] l [color=RED]([/color][color=BLUE]reverse[/color] l[color=RED]))))[/color]
             [color=RED]([/color][color=BLUE]cons[/color] [color=#009900]48[/color] l[color=RED])[/color]
           [color=RED])[/color]
           [color=RED]([/color] [color=RED]([/color][color=BLUE]and[/color] [color=RED]([/color][color=BLUE]=[/color] [color=#009900]45[/color] [color=RED]([/color][color=BLUE]car[/color] l[color=RED]))[/color] [color=RED]([/color][color=BLUE]=[/color] [color=#009900]46[/color] [color=RED]([/color][color=BLUE]cadr[/color] l[color=RED])))[/color]
             [color=RED]([/color][color=BLUE]cons[/color] [color=#009900]45[/color] [color=RED]([/color][color=BLUE]cons[/color] [color=#009900]48[/color] [color=RED]([/color][color=BLUE]cdr[/color] l[color=RED])))[/color]
           [color=RED])[/color]
           [color=RED]([/color] l [color=RED])[/color]
         [color=RED])[/color]
       [color=RED])[/color]
     [color=RED])[/color]
   [color=RED])[/color]
   [color=RED]([/color][color=BLUE]reverse[/color] [color=RED]([/color][color=BLUE]vl-string->list[/color] [color=RED]([/color][color=BLUE]rtos[/color] real [color=#009900]2[/color] prec[color=RED])))[/color]
 [color=RED])[/color]
[color=RED])[/color]

 

With only handle Decimal format, but no messing with DIMZIN :P

Posted

OK Lee, your skills are conciderably further advanced than mine! I like the idea of what you have there, but I don't know how to implement it. I need a little more instruction. How should I implement your code in my routine?

Here is my code (with the DIMZIN stuff in it).

 

; Jeff Clark 1/6/04
;reads a number (text), erases it, then inserts TCL or R, 
;filling in the atts for TC & BC
;
;BLOCK - TCL 6 INCH CURB .5"
(defun C:BC ()
(setq AD (getvar "attdia"))
;(setq DZ (getvar "DIMZIN"))
;(setvar "dimzin" 1)
(setvar "cmdecho" 1)
(setvar "attdia" 0)
(setq ENT1 (car (entsel)))
(setq BC (cdr (assoc 1 (entget ENT1))))
(setq TC (rtos (+ (atof BC) 0.5) 2 2)); <-- ADJUST FOR 4 OR 6 INCH CURB
(setq BC (rtos (atof BC) 2 2))
(command "erase" ENT1 "")
(command "insert" "TCL" "appint" pause "30" "" pause TC BC); <-- ADJUST BLOCK TCL OR TCR
(setvar "attdia" AD)
;(setvar "dimzin" DZ)
)

Posted

Hi Jeff,

 

Perhaps try something like this:

 

(defun c:BC ( / *error* ar block ent num tc bc )

 ;; Example by Lee Mac 2011  -  www.lee-mac.com

 (defun *error* ( msg )
   (if ar (setvar 'ATTREQ ar))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ)
 )

 (setq block "TCL") ;; Name of Block to insert

 (setq ar (getvar 'ATTREQ))
 (setvar 'ATTREQ 1)

 (cond
   (
     (not
       (setq ent
         (LM:Selectif
           (lambda ( x )
             (and (wcmatch (cdr (assoc 0 (entget x))) "ATTRIB,TEXT,MTEXT")
                  (distof  (cdr (assoc 1 (entget x))))
             )
           )
           nentsel "\nSelect Numerical Text: "
         )
       )
     )
    
     (princ "\n*Cancel*")
   )
   (t
     (setq num (distof  (cdr (assoc 1 (entget ent))))
           tc  (LM:rtos (+ num 0.5) 2)
           bc  (LM:rtos    num      2)
     )

     (setq elast (entlast))

     (command "_.-insert" block "_appint" pause 30.0 "" pause tc bc)

     (if (not (equal (entlast) elast)) (entdel ent))
   )
 )

 (setvar 'ATTREQ ar)
 (princ)
)


(defun LM:rtos ( real prec ) (vl-load-com)
 ;; © Lee Mac 2011
 (
   (lambda ( l )
     (repeat (- prec (cond ( (vl-position 46 l) ) ( (setq l (cons 46 l)) 0 )))
       (setq l (cons 48 l))
     )
     (vl-string-right-trim "."
       (vl-list->string
         (cond
           ( (= 46 (car (setq l (reverse l))))
             (cons 48 l)
           )
           ( (and (= 45 (car l)) (= 46 (cadr l)))
             (cons 45 (cons 48 (cdr l)))
           )
           ( l )
         )
       )
     )
   )
   (reverse (vl-string->list (rtos real 2 prec)))
 )
)

;;---------------------=={ Select if }==----------------------;;
;;                                                            ;;
;;  Continuous selection prompts until the predicate function ;;
;;  foo is validated                                          ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  foo - optional predicate function taking ename argument   ;;
;;  fun - selection function to invoke                        ;;
;;  str - prompt string                                       ;;
;;------------------------------------------------------------;;
;;  Returns:  selected entity ename if successful, else nil   ;;
;;------------------------------------------------------------;;

(defun LM:Selectif ( foo fun str / e )
 ;; © Lee Mac 2010
 (while
   (progn (setvar 'ERRNO 0) (setq e (car (fun str)))      
     (cond
       ( (= 7 (getvar 'ERRNO))

         (princ "\n** Missed, Try again **")
       )
       ( (eq 'ENAME (type e))

         (if (and foo (not (foo e)))
           (princ "\n** Invalid Object Selected **")
         )
       )
     )
   )
 )
 e
)

Uses the SelectIf sub from my site.

 

Lee

Posted

Lee, I just took you entire pile of code there and after much testing, it functions perfectly!!

Thanks!

Posted
Lee, I just took you entire pile of code there and after much testing, it functions perfectly!!

Thanks!

 

You're very welcome Jeff - I had fun with this one :)

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