replace objects


    Feb 19 2006 | 12:17 am
    hi,
    I need someone to confirm. I'd like to find and replace some objects in my patch as with the Max 'Edit' menu, but within my patch. Is there a javascript function for that or have I to delete an object, create another one and connect ? I searched thru the js guide and Max' tutorials for a replace function, but can't seem to find something. I'm still a really beginner with js and rather confused, so maybe I am missing it ?
    Thanks in advance.
    Best,
    Julien.

    • Feb 19 2006 | 5:06 am
      This would be quite tricky as the Javascript API won't give you information on connections, you cannot know if 2 boxes are connected or not...
    • Feb 19 2006 | 10:55 am
      Ok. Thank you for answer. That's not the answer I was hoping for, though. ;-)
      Maybe I'll try to think about another way to do it. Anyway, I'm not sure it really worth the effort, since I had a quite useless idea at the beginning. I was thinking it could be nice for my project for university to have one patch that could run on both PC and Mac. Then I was thinking about making an abstraction standing for 3d party objects (the abst would have the name of the object as argument). Then on initialization, the patch would replace the abstractions with appropriate objects placed on a 'pclib' or 'maclib' folders. But, well. For now, I only have the js to detect what is the os... I should probably make the whole patch before thinking about those kind of problems, hehe.
      Of course, I could simply make two versions in separate folders, but it is much less fun. :-)
      Julien.
    • Mar 05 2006 | 6:04 am
      Julien Rabin wrote: > Then I was thinking about making an abstraction standing for 3d > party objects (the abst would have the name of the object as > argument). Then on initialization, the patch would replace the > abstractions with appropriate objects placed on a 'pclib' or 'maclib' > folders. But, well. For now, I only have the js to detect what is > the os...
      But replace works with normal scripting, it would be possible to replace one object by another without knowing anything about connections (it would keep whats connected). Though usually Mac objects and PC objects which do the same do have the same name and wouldn't need any replacement...
      > I should probably make the whole patch before thinking about those > kind of problems, hehe.
      Thinking before patching isn't such a bad idea as it seems....
      Stefan
      --
      [][] [][][] [][] [][][] [][][][][][][][][][][][][][][]
      Stefan Tiedje Klanggestalter Electronic Composition & Improvisation
      /~~~~~ \ /|() ()| ))))) )| | |( \ /// _/)/ ))))) ___/ ///
      -------------------------x---- --_____-----------|----------- --(_|_ ----|-----|-----()---- -- _|_)----|-----()----------- ----------()------------x-----
      14, Av. Pr. Franklin Roosevelt, 94320 Thiais, France Phone at CCMIX +33-1-49 77 51 72
    • Mar 07 2006 | 12:27 am
      Quote: Stefan Tiedje wrote on Sun, 05 March 2006 07:04 > But replace works with normal scripting, it would be possible to replace > one object by another without knowing anything about connections (it > would keep whats connected).
      May I ask you how ? According to the Max Tutorials Manual :
      "You can use scripting to replace objects in a patcher and re-establish their previous connections. One important step in doing this is that all objects involved should be named prior to executing the script messages."
      It seems that the 'replace' message sent to a thispatcher no longer works. Were you refering to an other way to do it ? I'd be glad to hear since I haven't found another way yet (although I must admit I almost forget what I wanted to do since it was more or less useless, it could be interesting in another context)
      Julien.
    • Mar 07 2006 | 12:31 am
      The "replace" message to bpatcher no longer works. You want the "script replace" message to thispatcher. Works like "script new", but replaces an existing object with the same name (retaining connections as possible).
      jb
    • Mar 07 2006 | 12:42 am
      ah ok. I misunderstood. I thought it no longer worked for any object and not only for bpatchers.
      Thanks for help. I'll have a look at it tomorow. (Time for bed for now. ;-)
      Julien.