Jump to content

Lisp routine that will round decimal places


dpaulku

Recommended Posts

Works fine for me - what error do you get?

 

Well here's what I've done with all this code here:

 

Cut and paste into wordpad

 

save as text file w/.lsp extension

 

Say yes to loosing all the formating (that's just for show anyway right?)

 

Load into acad and process the command characters.

 

For the last one, I see "(defun c:2dp ( / ss ) " as the command info so I just type "2dp".

 

I get "Unknown command 2DP" back.

Link to comment
Share on other sites

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    16

  • alanjt

    15

  • dpaulku

    8

  • Tharwat

    8

Here's a better way to load it:

 

Open your drawing, type VLIDE at the command line, go to File > New File, Paste the code.

 

Click the load button, then type the command at the command line.

 

Else, I think Notepad is better to copy it to.

Link to comment
Share on other sites

Yeah, your response seemed a bit downhearted is all - so I hope I didn't step on your toes by diving in with new code.

 

Oh, not at all. That's why I ended that post with a smile. I had other pressing matters and you seemed eager to step in. It's not like we're getting paid for this stuff.

 

LoL, why'd you quote 'burst' and 'bubble'?

Link to comment
Share on other sites

I'm poised for a long weekend now that my mess is cleaned up. Thanks for all the help, I'll try to address my loading/saving issue next week.

 

Cheers!

Link to comment
Share on other sites

I'm poised for a long weekend now that my mess is cleaned up. Thanks for all the help, I'll try to address my loading/saving issue next week.

 

Cheers!

Always happy to save others time and money. :lol:

 

We make that our new CADTutor slogan.

Link to comment
Share on other sites

Oh, not at all. That's why I ended that post with a smile. I had other pressing matters and you seemed eager to step in. It's not like we're getting paid for this stuff.

 

Ok, no worries :)

 

LoL, why'd you quote 'burst' and 'bubble'?

Got that from you lol

Link to comment
Share on other sites

(defun c:R2D2 (/ ss)
 (if (setq ss (ssget "_:L" '((0 . "TEXT"))))
   ((lambda (i / e l)
      (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))
      )
    )
     -1
   )
 )
 (princ)
)

 

OK. Nice one..

And if I asked you to change this Lisp to another one things like mine that you commented in that forum, would you help with it ??????

 

I would like to know.

 

The always honest

Tharwat

Link to comment
Share on other sites

OK. Nice one..

And if I asked you to change this Lisp to another one things like mine that you commented in that forum, would you help with it ??????

 

I would like to know.

 

The always honest

Tharwat

Replace the lambda expression with (setq i -1)
Link to comment
Share on other sites

the following cod goes with no action'

(defun c:test (/ ss i e l)
 (if (setq ss (ssget "_:L" '((0 . "TEXT"))))
   [color="Red"](setq i -1)[/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))
      )
    )
 (princ)
)

Link to comment
Share on other sites

the following cod goes with no action'

(defun c:test (/ ss i e l)
 (if (setq ss (ssget "_:L" '((0 . "TEXT"))))
   [color=Red](setq i -1)[/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))
      )
    )
 (princ)
)

That's because you put it as part of the IF statement. Why are you trying to change what I posted? Don't fix what isn't broken.

Link to comment
Share on other sites

Why are you trying to change what I posted? :o

 

I am not changing any of yours and nor anyone ... I am here to get learned and help any if I could. and not to get complete codes or being lost by other's codes ideas... :wink:

 

I changed codes' variables that I posted earlier to meet your style, that's all.

 

And if you have noticed mine in the other forum you will find out that clearly, of course if you want to.

 

it is genuine ,

(defun c:2r (/ sel objs ents all)
(setq sel (ssget "_:L" '((0 . "TEXT"))))
 (setq objs -1)
  (while (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)
)

 

No giving up.

 

Tharwat

Link to comment
Share on other sites

IF will only take one statement as the 'then' expression and one statement as the 'else' expression.

 

Hence if you want to evaluate more than one expression on these conditions - they must be wrapped, perhaps using 'progn', so that they may be passed to the IF function as one expression.

Link to comment
Share on other sites

No giving up.

 

Tharwat

I give up. Why are you trying to rewrite a code that already works? We've all provided code that works and you are just trying to write it differently. If you don't understand what we did or a procedure we used, just asked us about it, instead of haphazardly trying to modify it to look more like something you would do.

Link to comment
Share on other sites

I give up. Why are you trying to rewrite a code that already works? We've all provided code that works and you are just trying to write it differently. If you don't understand what we did or a procedure we used, just asked us about it, instead of haphazardly trying to modify it to look more like something you would do.

 

First of all, I am sorry for being direct to points, but this is my conduct.

 

- I do not rewrite things that already made by anyone.Although in public.

- I have informed you before that this is not your post or idea, nor nothing

related.

- If I or anyone else asked for any small help, you would give not more than a

hint untill anyone write something any codes against it, so you will show the

abilities.

 

As you can see in all my posts, I don't ask for programs, I am still learning and getting information.

 

Sincerly

 

Tharwat

Link to comment
Share on other sites

You miss my point. There are several versions of exactly what you are trying to achieve. Why not try and understand how the existing ones work?

Link to comment
Share on other sites

You miss my point. There are several versions of exactly what you are trying to achieve. Why not try and understand how the existing ones work?

 

If I am not trying to understand codes in general, I won't be here. and if you go back somewhere you will find out that my words were correct and stright to the point.

 

I have asked you directly for a modification but you ignored that.

 

Thank you

 

Tharwat

Link to comment
Share on other sites

Ugh. Set your i variable before you select you text.

 

I have no i variable in my codes , haven't you noticed that, so what should I do with it (the i) variable ... ???????

(defun c:2r (/ sel objs ents all)
(setq sel (ssget "_:L" '((0 . "TEXT"))))
 (setq objs -1)
  (while (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)
)

 

Is it OK.

 

Tharwat

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