Detecting Max object types

I think a really simple question. Writing a script that manipulates Max text objects - including changing the text. For error checking i need to be able to tell if the selected object is a text object. If it's a mesh object like Sphere001, or Plane001, the script will die as

$.text

is undefined for those object types.

I'm looking for a conditional test that i can wrap around all my text control commands.

if ($ is a text object) then
(
do all the text stuff
)
else
(
warn user to select text object
)

Thanks!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barigazy's picture

to continue

other conditional tests:

if getclassname selection[1] == "Text" do...

You can also use unique text shape properties for checking like

obj = selection[1] -- define variable selection
if isProperty obj "kerning" do...
--or
if isProperty obj "leading" do...
--etc.

barigazy

barigazy's picture

to collect all text "stuffs" ;)

if selection.count != 0 do
(
	if iskindof (txt=selection[1]) text then
	(
		clearlistener()
		local props = getpropnames txt
		for i = 1 to props.count do format ("$"+txt.name+"."+props[i] as string + " = %\n") (getProperty txt props[i])
	)
	else messageBox "You need to pick text shape first!" title:"Warning" beep:off
)

Then open the listener to see the result

barigazy

miauu's picture

if classof $ == text then

if classof $ == text then ...
if isKindOF $ text then ...

or you can use

	if classof $.baseobject == text then ...
	if isKindOF $.baseobject text then ..
coyote808's picture

Thanks!

This forum is really a huge help to newbies. The Max Script docs are complete but there's so much detail. It's hard to know what to search for.

Thanks again - to both responders!

coyote808

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.