PDA

View Full Version : Select objects by Block sub objects


Billibong
11-17-2005, 09:42 PM
Hi,

I'm a newbee to Maxscript (although I know AutoLisp very well) and I'm finding it much harder to use maxscript because max itself is so much deeper than AutoCAD. Anyway-
I have 2 questions:
1. How do I select objects by block sub-objects?
2. How do I do string "strips" (in AutoLISP it's "Substr" function), so I can disect strings character by character?

Maybe there is an easier way altogether. What I'm tring to do is this: I have layers of doors that are getting imported from AutoCAD as 2d Block objects, each with a name that describes the door type and size. I'm writing a script to automatically substitute these blocks with Pivot doors. Typical name of a block would be SL-36x6x80, this is a Single pivot Left hand hinged door 36" wide, 6" deep, 80" high. So it would be great if I could strip out the name get the sizes and type and set them to variables to create new 3d doors.

Any help would be greatly appriciated...

Thanks,
Billibong

magicm
11-17-2005, 10:48 PM
The max equivalent of autocad's Substr function is substring

myString = "SL-36x6x80"
mySubstr = substring myString 4 2

would return "36"


To grab a single character from a string you can also use:

myString = "SL-36x6x80"
mySubstr = myString[3]

would return "-"


If the autocad objects are always named like SL-36x6x80 you may be better off using the filterString function:

myString = "SL-36x6x80"
myStringParts = filterString myString "-x"

would return the following array of strings : "SL", "36", "6" and "80"


To use these numeric parts as actual numbers in max you will need to convert them to integers. Here's an example:

myString = "SL-36x6x80"
myStringParts = filterString myString "-x"

doorType = myStringParts[1]
doorWidth = myStringParts[2] as integer
doorThickness = myStringParts[3] as integer
doorHeight = myStringParts[4] as integer


Check out the online reference for more info about substring and filterString.

Good luck ;)
Martijn

Billibong
11-18-2005, 01:31 PM
Hey Martijn,

Thanks alot for the info! Is there a good on-line reference file that just lists all the functions available in Maxscript? Also is there a way to easily select the sub-objects (children) of a block definition?

If I get this script working I'll post it and share it. I can think of many uses for this type of script in Arch Visualization, where we are always importing AutoCAD block info.

Thanks Again,
Bill

Billibong
11-20-2005, 01:45 PM
Hey,

I answered my own question-
To select block subobjects just select the block, then

Max select child

B

CGTalk Moderation
11-20-2005, 01:45 PM
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.