Notifications
Clear all

[Closed] SDK Merging

Hi again, I am trying to merge a file into the scene when I click a button. From the docs, I have be using the Mergefromfile void but it crashes max every time. Got any ideas why ?
Code is below :

theRender.ip->MergeFromFile(_T("C:\\Tree.max"),0, 0, 1, 0, NULL, 0 , 0);

Thanks

2 Replies

can you check to see if theRender.ip is valid ? eg not NULL ?

Hi, Yeah, theRender.ip is valid as I’m using it in another button. Here all the DlgProc code.

class RenderDlgProc : public ParamMap2UserDlgProc 
   {
   	public:			
  
   		INT_PTR DlgProc(TimeValue t, IParamMap2 *map, HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
   		{
   			Render_Object *p = (Render_Object*)map->GetParamBlock()->GetOwner();
   			switch (msg) 
   			{
   				case WM_INITDIALOG:
   				{
   					
   					break;
   				}
   				case WM_COMMAND:
   					switch( LOWORD(wParam) )
   						{
   							case IDC_CREATEBOXES:
   								theRender.CreateBoxes();
   								break;
   							case IDC_MERGE:
   								   ExecuteMAXScriptScript(_T("print \"NOT DONE\""), 0, 0);
   								theRender.ip->MergeFromFile(_T("C:\\Tree.max"),0, 0, 1, 0, NULL, 0 , 0);
   								 ExecuteMAXScriptScript(_T("print \"DONE\""), 0, 0);
   								break;
   						}
   					break;
   				default:
   					return FALSE;
   			}
   			return TRUE;
   		}
   
   		void DeleteThis() {};
   };

Edit* Sorry, Im not using on the Button xD But it is being using to create a GenSphere in my RenderNotify.

GenSphere *pSphere = (GenSphere*)theRender.ip->CreateInstance(GEOMOBJECT_CLASS_ID, Class_ID(SPHERE_CLASS_ID, 0));