Jump to content

Recommended Posts

Posted

Ok so i'm trying to wright my first autolisp but I've hit a road block. What I want to do is make a lisp that will take the area of an object and mlutiply it by a number then put both numbers into an MText along w/ the perimeter and insert next to the object. What I have written so far is

(defun C:AreaP ()
   (command "area" "o" pause)
   (setq AreaP (getvar Area))
   (setq PermP (getvar Perimeter))
   (setq AP (* areaP 1.2))
   (command "-mtext" pause)
   (princ AreaP)
   (princ AP)
   (princ PermP)
(princ)
)

The code above is from memory since I'm not at my computer atm. So far it all seems to work except when I get the point where I want the text in the mtext. in the first line of mtext is pastes all the values and then goes to the next line. How can I get each value on a seperate line and complete the mtext command? again thanks in advance.

Posted

Give this a look: :)

 

(defun c:AreaP (/ Ent Pnt AreaP PermP AP)
 (and (setq Ent (entsel "\nSelect object: "))
      (setq Pnt (getpoint "\nSpecify MText placement point: "))
      (progn
        (command "_.area" "_o" (car ent))
        (setq AreaP (getvar "area")
              PermP (getvar "perimeter")
              AP    (* AreaP 1.2)
        ) ;_ setq
        (princ (strcat "\nArea: "
                       (rtos AreaP 2 2)
                       "\nModified Area: "
                       (rtos AP 2 2)
                       "\nPerimeter: "
                       (rtos PermP 2 2)
               ) ;_ strcat
        ) ;_ princ
        (command "_.mtext" Pnt "_w" 0 "Area: " (rtos AP 2 2) "")
      ) ;_ progn
 ) ;_ and
 (princ)
) ;_ defun

Posted

wow that's pretty awesome. thanks a ton.

Posted
wow that's pretty awesome. thanks a ton.

I didn't over complicate it, since you seem to be a beginner. If you have any questions about it, feel free to ask. :)

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