Jump to content

Recommended Posts

Posted

Hi,

This is my very first post hope everyone is doing well. Anyway Im trying to use a variable within the dimpost command.

 

This works fine as is...but no variable yet...just a prefix to the dimension.

(command "dimpost" "SPACES @ 16\u+0022 = ")

 

This is what I would like to do...

(command "dimpost" "VAR1 SPACES @ 16\u+0022 = ")

VAR1 is the variable that I would like to show...not sure how to do the syntax.

 

Any help would be much appreciated...

 

Thanks

Posted (edited)

Welcome to CAD Tutor charlesV :)

 

Look into strcat function

Edited by pBe
Posted

You should have the variable VAR1 as string .

 

(strcat VAR1 "SPACES @ 16\u+0022 = <>")

Posted
Oops , pBe beat me to it :o

 

:D ... I only wanted to welcome the "new guy" to our wonderful forum.

 

You can expand your post and show more examples, that will be a nice welcome for CharlesV.

 

Cheers

Posted

Thanks for the welcome guys and your quick replies! So I need to create a new variable say VAR2 which will make VAR1 a string?

If so what would the code look like? Not sure how to make VAR1 a string.

 

so the code for my dimpost command would look like...

(command "dimpost" (strcat VAR2 "SPACES @ 16\u+0022 = ")

Posted

What is the value of the Var1 ?

And what is the use of the var2 you looking for ?

Posted

VAR1 will change depending on user input. As for VAR2 I dont need it....just thought I would have to create a new variable which converted VAR1 to a string for use in my dimpost code.

Posted (edited)

Check this simple routine ...

 

 

(defun c:var (/ var)
 (if (/= ""
         (setq var
                (getstring t "\n Enter string to be assigned to a prefix :")
         )
     )
   (setvar 'dimpost (strcat var " SPACES @ 16\u+0022 = <>"))
 )
 (princ)
)

Edited by Tharwat
a little bit extra codes removed
Posted

Is there anyway to avoid asking for additional user input?

The dimpost variable is changed just before placing the dimension

then back to normal after the dimension is placed. Was hoping to

just add the VAR1 to it.

Posted

I appreciate the help guys!! After looking at what you guys were suggesting I ended up with this...

 

(command "dimpost" (strcat (rtos var1 5 0) " SPACES @ 16\u+0022 = "))

 

B E A U T I F U L

 

I've been trying to get this to work for a while now...thanks to you guys its done!!

 

Thank you very much!!

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