<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: object merge by material in 3ds Max Programming Forum</title>
    <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205134#M20171</link>
    <description>hi,&lt;BR /&gt;&lt;BR /&gt;wow thank you for your fast response.&lt;BR /&gt;i think in principle this exactly what i need.&lt;BR /&gt;i run this on a simple test scene and getting an unknown system exception here.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;polyOp.attach newObj o&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;any idea?&lt;BR /&gt;&lt;BR /&gt;using max 2010&lt;BR /&gt;my test scene consits of 5 primitives and 2 scenematerials applied to those&lt;BR /&gt;so in the end there should be to editable polys&lt;BR /&gt;&lt;BR /&gt;thank you!</description>
    <pubDate>Thu, 19 May 2011 11:15:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-05-19T11:15:03Z</dc:date>
    <item>
      <title>object merge by material</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205132#M20169</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;i got 21000 objects in my scene and there are 1500 scenematerials.&lt;BR /&gt;i want to attach all objects with the same material applied.&lt;BR /&gt;in the end there should be 1500 objects.&lt;BR /&gt;i think it is not possible to do it manually for this quantity of objects (pick material - select objects by material - attach ...) &lt;BR /&gt;i think there should be a better maxscript solution ... i am really new to maxscript, so any help would be appreciated.&lt;BR /&gt;&lt;BR /&gt;one way could be. replace objectname with materialname (they are unique) &amp;gt;&amp;gt; check if objectname is assigned multiple times &amp;gt;&amp;gt; if so &amp;gt;&amp;gt; select objects by this name &amp;gt;&amp;gt; attach &amp;gt;&amp;gt; if not it is already processed ... end of loop&lt;BR /&gt;&lt;BR /&gt;thank you&lt;BR /&gt;&lt;BR /&gt;regards sebastian</description>
      <pubDate>Thu, 19 May 2011 09:17:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205132#M20169</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-05-19T09:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: object merge by material</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205133#M20170</link>
      <description>Things to note...&lt;BR /&gt;&lt;BR /&gt;If you managed to get 2 or more materials with the same name, this will fail. It assumes that the materials are Instanced to the objects.&lt;BR /&gt;&lt;BR /&gt;Attaching that many objects is slow and fills up the Undo stack rapidly, which uses a lot of memory. The code attempt to mitigate those problems, but it means there is no going back once you have run the script. You MUST ensure your scene is saved before running it.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;(&lt;BR /&gt;suspendEditing()&lt;BR /&gt;disableSceneRedraw()&lt;BR /&gt;with undo off&lt;BR /&gt;   (&lt;BR /&gt;   for m in sceneMaterials do&lt;BR /&gt;      (&lt;BR /&gt;      newObj = Editable_Mesh()&lt;BR /&gt;      convertTo newObj Editable_Poly&lt;BR /&gt;      newObj.name = "Object_" + m.name&lt;BR /&gt;      for o in geometry where (o.material == m) do&lt;BR /&gt;         polyOp.attach newObj o&lt;BR /&gt;      centerPivot newObj&lt;BR /&gt;      )&lt;BR /&gt;   )&lt;BR /&gt;enableSceneRedraw()&lt;BR /&gt;resumeEditing()&lt;BR /&gt;)&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 May 2011 10:02:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205133#M20170</guid>
      <dc:creator>Steve_Curley</dc:creator>
      <dc:date>2011-05-19T10:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: object merge by material</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205134#M20171</link>
      <description>hi,&lt;BR /&gt;&lt;BR /&gt;wow thank you for your fast response.&lt;BR /&gt;i think in principle this exactly what i need.&lt;BR /&gt;i run this on a simple test scene and getting an unknown system exception here.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;polyOp.attach newObj o&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;any idea?&lt;BR /&gt;&lt;BR /&gt;using max 2010&lt;BR /&gt;my test scene consits of 5 primitives and 2 scenematerials applied to those&lt;BR /&gt;so in the end there should be to editable polys&lt;BR /&gt;&lt;BR /&gt;thank you!</description>
      <pubDate>Thu, 19 May 2011 11:15:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205134#M20171</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-05-19T11:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: object merge by material</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205135#M20172</link>
      <description>I can only assume that you somehow have a scene material which is not actually applied to any geometric objects.&lt;BR /&gt;&lt;BR /&gt;You should end up with an Editable Poly object for each material in the scene. It should attach objects which are not already Editable Polys because the Attach method is supposed to automatically convert the object to a Polymesh, so a Box primitive or even an Editable Mesh object should attach just fine. The code does work here, so if the modified version below doesn't, then it will be difficult to work out what is wrong without having the actual scene to look at.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;&lt;BR /&gt;(&lt;BR /&gt;suspendEditing()&lt;BR /&gt;disableSceneRedraw()&lt;BR /&gt;with undo off&lt;BR /&gt;   (&lt;BR /&gt;   for m in sceneMaterials do&lt;BR /&gt;      (&lt;BR /&gt;      newObj = Editable_Mesh()&lt;BR /&gt;      convertTo newObj Editable_Poly&lt;BR /&gt;      newObj.name = "Object_" + m.name&lt;BR /&gt;      objs = for o in geometry where (o.material == m) collect o&lt;BR /&gt;      if objs.count &amp;gt; 0 then&lt;BR /&gt;         (&lt;BR /&gt;         for o in objs do&lt;BR /&gt;            (&lt;BR /&gt;            polyOp.attach newObj o&lt;BR /&gt;            centerPivot newObj&lt;BR /&gt;            )&lt;BR /&gt;         )&lt;BR /&gt;      )&lt;BR /&gt;   )  &lt;BR /&gt;enableSceneRedraw()&lt;BR /&gt;resumeEditing()&lt;BR /&gt;)&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 May 2011 11:49:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205135#M20172</guid>
      <dc:creator>Steve_Curley</dc:creator>
      <dc:date>2011-05-19T11:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: object merge by material</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205136#M20173</link>
      <description>thank you very very very much!!!&lt;BR /&gt;you saved my day &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; it is working ...&lt;BR /&gt;&lt;BR /&gt;regards sebastian</description>
      <pubDate>Thu, 19 May 2011 12:16:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205136#M20173</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-05-19T12:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: object merge by material</title>
      <link>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205137#M20174</link>
      <description>Cool - glad it helped. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Thu, 19 May 2011 12:24:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/3ds-max-programming-forum/object-merge-by-material/m-p/4205137#M20174</guid>
      <dc:creator>Steve_Curley</dc:creator>
      <dc:date>2011-05-19T12:24:15Z</dc:date>
    </item>
  </channel>
</rss>

