PDA

View Full Version : Trying to convert a String variable in a $thing...


altusi
01-18-2008, 04:59 PM
Hi there!
I'm trying to do I guess one of the easiest thing in the world with Maxscript but I just can't!
I've read every ms or mcr files, the whole Maxscript reference thing and I can't put a hand on it!
Whatever
I just want to have an input box in which I write the name of the object I want to select, then push a button on the left, and Max select the object!
In the end I just want as said before, to convert a String variable "Nameofobject" in a $Nameofobject thing so that I can put a:
select $Nameofobject

here's an exemple:

rollout unnamedRollout "Select it" width:222 height:77
(
editText input "Name ofobject" pos:[10,9] width:199 height:22
button btn1 "SELECT" pos:[16,36] width:186 height:33

on input entered youpi do
(
// messagebox "You want to select" input.text
)

on btn1 pressed do
(
// select youpi.name
)
)
createDialog unnamedRollout 230 80


where you can find a "//" there is a problem, guess you've seen it before ;-)
the second "//" is what I am talking about but it should be easy for you to correct the first one ;-)
If you could help!
Thanks a lot!
see ya!!

RustyKnight
01-20-2008, 09:57 AM
Basically, yes it possible, yes it asked often and yes it can be difficult to find...
rollout unnamedRollout "Select it" width:222 height:77
(
editText input "Name ofobject" pos:[10,9] width:199 height:22
button btn1 "SELECT" pos:[16,36] width:186 height:33

fn selectMyObject()
(
local obj = getNodeByName input.text
if obj != undefined then (

select obj

) else (

messagebox "The object you're looking for doesn't exist"

)
)


on input entered youpi do
(
selectMyObject()
)


on btn1 pressed do
(
selectMyObject()
)
)
createDialog unnamedRollout 230 80This is untested and done without the benifit of the docs, so there might be some other issues I haven't thought of, but it's a start

Shane

Bobo
01-20-2008, 02:15 PM
Uhhm, I disagree with passion!

The MAXScript Reference has a Frequently Asked Questions section, which contains a "How do I get the object by object name?" topic with two possible solutions.

If one would enter in the Search tab of the Reference "convert string variable to $", the first hit already reveals the topic "String Values" which shows how to use execute() to do this, the 6th hit is the FAQ entry and the 7th hit is the "Node Common Properties" topic where getNodeByName() is documented. (the actual Rank numbers might vary from version to version, but this should work since at least Max 6 when the FAQ was added).

So when I see "I read the whole Help and could not find it", please excuse me if I don't believe it :twisted:

RustyKnight
01-20-2008, 09:15 PM
Uhhm, I disagree with passion!Can't argue with that ;)
The MAXScript Reference has a Frequently Asked Questions section, which contains a "How do I get the object by object name?" topic with two possible solutions.

If one would enter in the Search tab of the Reference "convert string variable to $", the first hit already reveals the topic "String Values" which shows how to use execute() to do this, the 6th hit is the FAQ entry and the 7th hit is the "Node Common Properties" topic where getNodeByName() is documented. (the actual Rank numbers might vary from version to version, but this should work since at least Max 6 when the FAQ was added).I guess it depends on what you are looking and knowing what to look for. I know it took me a while to find this marvlous little function, but I probably skimmed over it a few times before I know what I was looking for...I guess it also helps to be able to use the help as well...;)

So when I see "I read the whole Help and could not find it", please excuse me if I don't believe it :twisted:You your self have always stated that one should not read the docs from start to finish, as that is not what how they were designed. So frankly, I agree.

Besides, had they made a some small effort to search the forum, they would have found the answer to their question...if they knew what they were looking for...

Having said all that, we are here but to help and as annoying as it can be, most people learn quick...besides, you won't get an arguement from me ;)

Shane

Bobo
01-20-2008, 09:50 PM
Oh, I have no problem with answering the same question 100 times, don't get me wrong. (Especially when I did not have to answer it after you did ;)) But I sometimes take it personally when someone says "I cannot find it in the Help" when it was specifically placed in the FAQ section extracted from this and the Autodesk forums with the intention to be found. :)

There are many many cases where the Help is not helpful enough - in the last couple of days I have added a lot of examples to it right after answering a question here because I realized people were confused.

I guess I was in the wrong mood this morning... Sorry for the rant!

RustyKnight
01-20-2008, 11:53 PM
Mate, if you're not allowed to rant from time to time, I don't know who is!

The help can take a little getting use to (and of course as professional software developers, we don't like to have to admit we need to read the docs ;)), but it is an invaluable reference point, and so is this fourm!

I can't tell how much I appriciate all the work you have done on the help docs!

Shane

PEN
01-21-2008, 11:29 AM
Bobo you do a killer job on the docs, ever time I start to teach a new group of people I find it easier and easier as the docs do half of it for me.

CGTalk Moderation
01-21-2008, 11:29 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.