Jump to content

Recommended Posts

Posted

Hi Cadtutors

 

Could anybody please let me know how to invoke text command so that what ever result i am "princ"ing to command line.

i want to be able to paste it on screen through text command, pick a point where the "princ" result is ready to be placed in model space.

 

 

;|  ARSQ, Area and Perimeter of Rectangle when Length and Width are known 
   

Variables 
len     Length of Rectangle 
wid   	Width of Rectangle     |;

(defun c:arsq()
(setq len ( getreal "\nEnter Length Of Rectangle \n"))
(setq wid ( getreal "\nEnter Widh Of Rectangle \n"))
(setq peri (* len wid))
(princ (strcat "\nThe Area Of Rectangle is = " (rtos peri 2 4 ) " Sqm"))
(setq are (* 2 (+ len wid)))
(princ (strcat "\nThe Perimeter Of Rectangle is = " (rtos are 2 4 ) " Sqm"))
(princ)
)

 

Thanks in Advance.

Cadsterdyne

Posted

This?

(defun c:arsq (/ len wid pnt are per)
 (and (setq len (getreal "\nEnter Length Of Rectangle :"))
      (setq wid (getreal "\nEnter Widh Of Rectangle :"))
      (setq are (strcat "The Area Of Rectangle is = " (rtos (* len wid) 2 4) " Sqm"))
      (setq per (strcat "The Perimeter Of Rectangle is = " (rtos (* 2 (+ len wid)) 2 4) " Sqm"))
      (princ (strcat "\n" are))
      (princ (strcat "\n" per))
      (setq pnt (getpoint "\nSpecify text location :"))
      (entmake (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText")
          (cons 10 (trans pnt 1 0))
          (cons 40 (* (getvar "DIMSCALE") 2.0))
          (cons 7 (getvar 'TEXTSTYLE))
          (cons 1 (strcat are "\\P" per))
        )
   )
 )
 (princ)
 )

Posted

Exactly what i meant Tharwat!

Thank you so much.

 

I can see the changes you added to the code. as i am a beginner at learning AutoLISP, could you please direct me to some place where i can lookup details about invoking commands?

as i see you didnt use

command ".text"

to accomplish the above requirement. i dont even know if that exist's. or is the right way to go, i want to learn more about code formats for various commands. i hope i am conveying what iam trying to learn.

 

Thanks again.

Posted (edited)

You are welcome :)

 

Actually I used the entmake function instead of command call which is better in all cases and specially when you have many object to be created which the factor of speed would force its self in this ring.:D besides that programming is not a use of command unless you have no better go with your aim of a program.

 

Hit THIS for more information about entmake function.

Edited by Tharwat
words missing added
Posted

Thank you for the enlightenment Tharwat. Point Noted.

:notworthy:

Posted
You are welcome :)

 

Actually I used the entmake function instead of command call which is better in all cases and specially when you have many object to be created which the factor of speed would force its self in this ring.:D besides that programming is not a use of command unless you have no better go your aim of a program.

 

Hit THIS for more information about entmake function.

very nice Thaerwat!

Posted

Many thanks samifox for your reply. Highly appreciated. :thumbsup:

 

It would be nice of you if you write my name correctly.

Posted

cadsterdyne when using command there are switches you can use . - _ I am trying to find the details if I remember right the . is language so a German Autocad would see command as just that. Just at command line type LA and see what happens then do -LA An example if using command in lisp often need say -hatch so no dialouge will open and an area is hatched.

Posted
Just at command line type LA and see what happens then do -LA .

 

Thanks BIGAL i see how that can add to a speedy workflow. Thanks for sharing. :thumbsup:

Posted

 

Actually I used the entmake function instead of command call which is better in all cases and specially when you have many object to be created which the factor of speed would force its self in this ring.

 

On the lines of Speed in Code found this interesting.

(entmake) vs (command) vs (vla-add-) Speed Test!!

http://cadpanacea.com/wp/?p=1542

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