Jump to content

Recommended Posts

Posted

Hi,

I have been racking my brains to amend this lisp to do what i want and have failed.... so i ask you the gods of lisp for some help.

I have acquired a lisp file via google AI that will set the elevation (z axis) of a poly line, easier to just select the pline and type in the elevation i hear you cry....

But my cunning plan was to amend the elevation of said pline by selecting the pline then select the text/mtext next to it.....

I thought i could add some command to do this by looking at another lisp i have that does a similar thing, but i am a numpty and have given up....

I know there are many wise men out there that could just type some lines with their eyes shut and solve my problem...

Obviously i would be greatly indebted to such persons and wish boundless fortune upon them granting wishes galore if i could...

Also I just want an easy life as i approach retirement and thinking for gets in the way of thinking for myself.....

Begging you nicely..

 

Paul

SetPlineZ.lsp

Posted (edited)

@PaulyPHI Give this a try.SetPlineZ_Updated.lsp

Edited by pkenewell
Edited to change (atof) to (distof) to cover more numerical types, i.e. fractions - Thanks darshjalal for the idea in his code.
  • Like 1
  • Agree 2
  • Thanks 1
Posted
On 5/22/2026 at 5:22 PM, pkenewell said:

@PaulyPHI Give this a try.SetPlineZ_Updated.lsp

Thank you very much sir, works perfect.

 

I have compared the modified text file to the original and my brain just melted....

i can see some text that makes sense but the rest is just gobldee goop to me....

I'm just not programmed to understand it...

 

Thank you once again.

  • Like 1
Posted

@PaulyPHI Here is a quick walk-though: This uses Visual LISP to pull the text string from the selected object and convert it to a real number. See the added comments below.

(if 
   (and ;; Logical AND = All conditions must be met.
      
      ;; 1) an object must be selected.
      (setq es (entsel "\nSelect Text Object: "))
      
      ;; 2) The selected object must have a text string property, i.e. TEXT, MTEXT, ATTRIBUTE, MLEADER, etc.
      (vlax-property-available-p (vlax-ename->vla-object (car es)) 'TextString)
      
      ;; 3) Retrieve the textsting value if the above conditions are met.
      (setq newZ (vla-get-textstring (vlax-ename->vla-object (car es))))
      
      ;; 4) The textstring value must evaluate to greater than 0 when converted to a real number. This only works if the text is numerical.
      (> (setq newZ (atof newZ)) 0.0)
   ) ;; if all conditions are met, then continue to the (progn) block that performs the changes.
   

 

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