Jump to content

Recommended Posts

Posted
Is it OK.

 

You need an IF statement to allow for null input - see my post earlier.

 

I agree with Alan here though - rewriting code and just changing the variables is not the best way to learn and it will irritate those whose code you are mutilating.

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    16

  • alanjt

    15

  • dpaulku

    8

  • Tharwat

    8

Posted
You need an IF statement to allow for null input - see my post earlier.

 

Yes, you are right Lee, Thank you for helping me.

I did remodified it and here it goes.

(defun c:well (/ sel objs ents all)
(if (/=(setq sel (ssget "_:L" '((0 . "TEXT,MTEXT"))))nil)
 (progn
  (setq objs -1)
   (setq ents (ssname sel (setq objs (1+ objs))))
   (setq all (entget ents))
    (entmod (subst (cons 1 (rtos (atof (cdr (assoc 1 all)))2 2)) (assoc 1 all) all))
     )
     )
  (princ)
)

 

Best regards

 

Tharwat

Posted

You can try this, but it goes with one selection and I don't know why..

(defun c:try (/ sel objs ents all)
(if (setq sel (ssget "_:L" '((0 . "TEXT,MTEXT"))))
 (progn
  (setq objs -1)
   (setq ents (ssname sel (setq objs (1+ objs))))
    (setq all (entget ents))
     (entmod (subst (cons 1 (rtos (atof (cdr (assoc 1 all)))2 2)) (assoc 1 all) all))
      )
       (princ))
)

 

Michaels

Posted

Because you have no While loop.

 

Seriously guys - there are working codes earlier in this thread before you guys mutilated them.

Posted
Because you have no While loop.

 

Seriously guys - there are working codes earlier in this thread before you guys mutilated them.

 

Mr Lee

your codes are so hard for me and for lots of people to understand, would you please say what you are indicating to clearly ...?

 

Michaels

Posted
Mr Lee

your codes are so hard for me and for lots of people to understand, would you please say what you are indicating to clearly ...?

 

Michaels

 

Thank you Michaels.

 

Here it goes right now you can share it with me.

(defun c:try (/ sel objs ents all)
(setq sel (ssget "_:L" '((0 . "TEXT,MTEXT"))))
  (setq objs -1)
   [color="Red"](while[/color] (setq ents (ssname sel (setq objs (1+ objs))))
    (setq all (entget ents))
     (entmod (subst (cons 1 (rtos (atof (cdr (assoc 1 all)))2 2)) (assoc 1 all)       
       all))
      )
       (princ)
)

 

Sincerly

 

Tharwat

Posted
Replace the lambda expression with (setq i -1)

 

(defun c:R2D2 (/ ss)
 (if (setq ss (ssget "_:L" '((0 . "TEXT"))))
   [color=Red][b]((lambda (i / e l)[/b][/color]
      (while (setq e (ssname ss (setq i (1+ i))))
        (setq l (entget e))
        (entmod (subst (cons 1 (rtos (atof (cdr (assoc 1 l))) (getvar 'lunits) 2)) (assoc 1 l) l))
      )
    )
[color=Red][b]      -1
   )[/b][/color]
 )
 (princ)
)

 

(defun c:R2D2 (/ ss [b][color=Red]i[/color][/b])
 (if (setq ss (ssget "_:L" '((0 . "TEXT"))))
[color=Red][b]   (progn
     (setq i -1)[/b][/color]
     (while (setq e (ssname ss (setq i (1+ i))))
       (setq l (entget e))
       (entmod (subst (cons 1 (rtos (atof (cdr (assoc 1 l))) (getvar 'lunits) 2)) (assoc 1 l) l))
     )
[color=Red][b]    )[/b][/color]
 )
 (princ)
)

 

All I'm saying is that instead of complaining that something doesn't work, look at the working code and compare it.

  • 2 weeks later...
Posted

the R2D2 routine works fine, many thanks

  • 1 month later...
Posted

Just found this posting via Google, thanks for the lisp folks!

  • 4 years later...
Posted (edited)
Not much different from Alan's code, keeping with the theme lol

 

(defun c:C3PO ( / ss )

 (if (setq ss (ssget "_:L" '((0 . "TEXT"))))
   (
     (lambda ( i / e el )
       (while (setq e (ssname ss (setq i (1+ i))))
         (if (distof (cdr (assoc 1 (setq el (entget e)))))
           (entupd
             (cdr
               (assoc -1
                 (entmod
                   (subst
                     (cons 1
                       (rtos
                         (atof
                           (cdr
                             (assoc 1 el)
                           )
                         )
                         (getvar 'LUNITS)
                         2
                       )
                     )
                     (assoc 1 el)
                     el
                   )
                 )
               )
             )
           )
         )
       )
     )
     -1
   )
 )
 (princ)
)
                              

That's brilliant. Now, how do I force it to 2 decimals the other way? like 21.5 to 21.50 or 21.501 to 21.50. It doesn't seem to work. In both cases, the result produces 21.5. Thanks Lee Mac. I love your align to curve routine.

 

Update: Setting DIMZIN to 0 fixed it.

Edited by wing
Update

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