Forum Groups
  All forums
    Help & Feedback
      Work in progress
      Finished Art
      Non-Max related

Featured Threads
  inspiration alert!!!
(37 replies)
  Indespensible MaxScripts, Plugins and 3rd Party Tools
(37 replies)
  The allmighty FREE Resources Thread !
(17 replies)
  spam alert!!!
(4886 replies)
  Maxforums member photo gallery index
(114 replies)
  Maxforums Member Tutorials
(89 replies)
  three cheers to maxforums...
(240 replies)
  101 Things you didnt know in Max...
(198 replies)
  A Face tutorial from MDB101 :D
(95 replies) Members Gallery
(516 replies)
(637 replies)
  Dub's Maxscript Tutorial Index
(119 replies)

Maxunderground news unavailable

Unable to convert to string? Also superclasses not the same?
show user profile  jpedleham
fn replaceModels str =
data = filterstring str "~"
name = data[2]
file = data[3]
models = getnodebyname name all:on
if models.count > 0 and doesfileexist file do
names = getMAXFileObjectNames file quiet:on
if finditem names name > 0 do
count = objects.count
mergeMAXFile file (name) #noRedraw #mergeDups #useMergedMtlDups #neverReparent
if count < objects.count do
target = objects[objects.count]
for model in models do
mat = model.mat
instancereplace model target
model.mat = mat
delete target

Hi, This code has been somewhat working for the past few days whilst debugging. By somewhat i mean it almost does what i need it to. Anyway now for some reason without changing anything it is firing out an error

>> MAXScript FileIn Exception:
-- Unable to convert: #("Cylinder001") to type: String <<

And i have no idea why.
The code was written for me by a very nice user over on CGTalk forums in response to a question i asked about reading in lines of text from a file and replacing anything in the scene that matches the filename. Its meant for loading in the 3d model equivalent of CAD blocks. Whilst im on this if anything knows why im getting;

-- Runtime error: Controller superclasses not the same <<

On the line

replaceinstances model target

The model loads in but doesnt align with the target object then it throws that error.
Any help is greatly appreciated!!
read 1054 times
5/17/2015 6:00:31 PM (last edit: 5/17/2015 6:00:31 PM)
show user profile  Garp
You should probably ask the guy who helped you in the first place. He already knows the code.

At first glance, I see instancereplace in your code and replaceinstances in the error report. This looks suspicious.

read 1039 times
5/17/2015 6:50:15 PM (last edit: 5/17/2015 6:50:15 PM)
show user profile  jpedleham
Hey Garp,

Yeah i did ask but his reponse was that he wrote the code blind without testing and he doesnt know how my scene is organised and that theres enough there to get it working. Whilst im grateful for the code he wrote it doesnt look like ill be getting much more help there.
I can understand what the code is doing i just dont know the maxscript syntax well enough to know what needs fixing here.

Sorry that was my bad re: the error report i mistyped.

Just for context, this script would eventually be used by myself to make my job a little easier. we currently have a locked down and encryped script that deals with the cad blocks we get sent from the planners . The script however cant be updated to use new cad blocks so im trying to figure out if we can store the block names and the path to the correct model in a text file, then just read those in and merge them in the place of the cad blocks. Its what our current system does but this would be much more customisable in terms of being able to add our own new data and functionality into the system.
read 1037 times
5/17/2015 7:07:01 PM (last edit: 5/17/2015 7:07:01 PM)
show user profile  jpedleham
By the way its being fed a string in the function call (which will eventually be read from the text file)

replaceModels "~cylinder~Cylinder001~C:\Users\Jack\Desktop\cylinder.max"
read 1034 times
5/17/2015 8:02:20 PM (last edit: 5/17/2015 8:02:20 PM)
show user profile  jpedleham
Bumpity Bump

Ive read through the maxscript help and countless forums and i still cant figure out why it wont replace the objects in situ. Id really appreciate some guidance on this, even if its just to a resource where i might be able to learn and figure out whats going on myself?

read 972 times
5/21/2015 9:14:33 PM (last edit: 5/21/2015 9:14:33 PM)
show user profile  Garp
> i just dont know the maxscript syntax well enough to know what needs fixing

Changing this would be a good place to start ;)

The code you posted is too big and contextual. Isolate the problem. Build a simple example with everything that's needed and nothing more. Then come back and get helped. (Though chances are that you'll figure it out by yourself in the process).

read 968 times
5/21/2015 10:08:53 PM (last edit: 5/21/2015 10:09:12 PM)
show user profile  jpedleham
Im trying my best to keep learning maxscript in the spare time i have outside of work and slowly im learning the structure so thats at least a start.

I did infact create a simple file with only what i needed in and it still doesnt bring in the model to align with the cad block unfortunately.

Ill do some more research and keep trying :)

read 960 times
5/21/2015 11:24:40 PM (last edit: 5/21/2015 11:24:40 PM)
show user profile  jpedleham
Ok im pretty much at my wits end with this now. Ive been googling all weekend trying allsorts of stuff, dissecting other replacer scripts and i cant see how they are doing their replacing any other way that what i have here.

i have put together a zip file with a test scene, the object to be replaced and the script file and id really appreciate it if someone would just take a quick look for themselves and see if they can address the problem im having.

In the script there is a line

replaceModels "~DESCRIPTION_GOES_HERE~Box001~C:\Users\Jack\Desktop\cylinder_coloured.max"

Just replace the path to cylinder_coloured.max with the path to the downloaded cylinder file and run.

Thanks to anyone who takes the time to have a look.
read 935 times
5/25/2015 1:35:05 PM (last edit: 5/25/2015 1:35:05 PM)
#Maxforums IRC
Open chat window