Jump to content

Lisp for Multiplication


anwar186

Recommended Posts

Maybe starting with quick  dirty code lines :


(defun c:foo()
(ssget (list (cons 0 "*TEXT")))
(vlax-for obj (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (vla-put-textstring 
        obj
        (rtos (* (distof (vla-get-textstring obj)) 1000.0) 2 3)
    )
)
(princ)
)
(vl-load-com)

  • Like 1
Link to comment
Share on other sites

  • 2 years later...
On 12/20/2018 at 12:35 AM, Lee Mac said:

You can use this and simply change the "+" to "*":


(+ x *inc*)

Becomes:


(* x *inc*)

 

Lee, thank you for this. The only problem I'm facing is that the final text result prefixes a number before it. For example if I want 1103.944 multiplied by 1.3, the end result will be .300;1435.127. 

Same for if I want it multiplied by 1.4. It will prefix .4 before the result. 

Screenshot 2021-11-02 142451.jpg

Link to comment
Share on other sites

By any chance, is the object in question MText containing formatting applied through the MText editor? My guess is that my program is also applying the arithmetic operation to the MText formatting codes embedded within the MText content.

Link to comment
Share on other sites

2 hours ago, Lee Mac said:

By any chance, is the object in question MText containing formatting applied through the MText editor? My guess is that my program is also applying the arithmetic operation to the MText formatting codes embedded within the MText content.

Yes exactly, it is MText. Should I explode to Text and then run the lisp? For now my workaround was just using Find to pick all the prefixes and replacing them with an empty space. 

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