×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Convert dims to text LISP..

Convert dims to text LISP..

Convert dims to text LISP..

(OP)
Hi,

I not too hot on LISP so can anyone help me out on this one?

I want to write a small routine to allow the user to pick one or multiple dimensions and convert the dimensional values into a text version of that dim instead, like typing it in the override property areas..
Anyone know where to start with this?

     Cheers,

Paul
basepointdesignzltd..
P4 3.0Ghz / 2GB RAM
XP Pro SP2
Sapphire X1950 512MB Dual-DVi Graphics Card..

RE: Convert dims to text LISP..

Here's some lisp for picking one at a time.  You could put it in a selection loop to more easily do multiple single picks by changing the first line to (while (setq (Diment etc....

Enjoy!

CODE

(defun c:hcd ()
  (setq DimEnt (car (entsel "\nSelect dimension to override: ")))
  (setq DimData (entget DimEnt))
  (setq DimVal (cdr (assoc 42 DimData)))
  (setq DimStyleName (cdr (assoc 3 DimData)))
  (setq DimTableData (tblsearch "DIMSTYLE" DimStyleName))
  (setq NumDec (cdr (assoc 271 DimTableData)))
  (setq DimLengthUnit (cdr (assoc 277 DimTableData)))
  (if (not DimLengthUnit) (setq DimLengthUnit (getvar "LUNITS")))
  (setq Ltext (rtos DimVal DimLengthUnit NumDec))
  (setq NewDimData (subst (cons 1 Ltext) (assoc 1 DimData) DimData))
  (entmod NewDimData)
  (princ)
)

RE: Convert dims to text LISP..

(OP)
That's perfect, thanks so much - works perfectly and is exactly what i asked for..

I added the while so can pick multiples but how can i sort out a window select for multiples rather than picking each in turn?

     Cheers,

Paul
basepointdesignzltd..
P4 3.0Ghz / 2GB RAM
XP Pro SP2
Sapphire X1950 512MB Dual-DVi Graphics Card..

RE: Convert dims to text LISP..

Yeah OK, I figured that was going to be the next request if you weren't a lisper....

CODE

(defun c:hcd ()
  (princ "\nSelect dimensions to override: ")
  (setq DimSet (ssget '((0 . "DIMENSION"))))
  (if DimSet
     (progn
        (setq NumItems (sslength DimSet))
        (setq Count 0)
        (repeat NumItems
           (setq DimEnt (ssname DimSet Count)
                 DimData (entget DimEnt)
                 DimVal (cdr (assoc 42 DimData))
                 DimStyleName (cdr (assoc 3 DimData))
                 DimTableData (tblsearch "DIMSTYLE" DimStyleName)
                 NumDec (cdr (assoc 271 DimTableData))
                 DimLengthUnit (cdr (assoc 277 DimTableData))
           )
          (if (not DimLengthUnit) (setq DimLengthUnit (getvar "LUNITS")))
          (setq Ltext (rtos DimVal DimLengthUnit NumDec))
          (setq NewDimData (subst (cons 1 Ltext) (assoc 1 DimData) DimData))
          (entmod NewDimData)
          (setq Count (1+ Count))
        );repeat
     );
  )
  (if DimSet
      (princ (strcat (itoa NumItems) " dimensions overriden with text dimension"))
      (princ "\n**No dimensions selected**")
  )
  (princ)
)

RE: Convert dims to text LISP..

(OP)
You are in fact a genious! That works prefectly, just what i was after. Thanks Carl..

     Cheers,

Paul
basepointdesignzltd..
P4 3.0Ghz / 2GB RAM
XP Pro SP2
Sapphire X1950 512MB Dual-DVi Graphics Card..

RE: Convert dims to text LISP..

You're welcome, glad to help.  If I am a genious, it wasn't needed for this routine, just a little experience, and trial & error.

RE: Convert dims to text LISP..

(OP)
I need to learn a bit more lisp really - i know some but very limited - i'm more of a vba man myself..

     Cheers,

Paul
basepointdesignzltd..
P4 3.0Ghz / 2GB RAM
XP Pro SP2
Sapphire X1950 512MB Dual-DVi Graphics Card..

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close