7 Replies Latest reply on Feb 8, 2014 5:51 PM by Artem Taturevych

    SaveAs() error code 256 with *.SLDASM extension

    Robert Owens

      I have seen a few people commenting on others' posts saying they are unable to SaveAs() an assembly, but no one has directly responded to them. They receive the invalid extension 256 error code, but if they try either the IModelDoc2 or IModelDocExtension SaveAs() functions on a part file, it works without issue!

       

      I open a new document with the assembly template, but I continuously get the 256 error when I try to save it as a *.SLDASM file. When I use SW interactively, this is the choice it gives me. I have also tried *.sldasm in the event that it mattered.

       

      What is going on here? Are you not able to open a new document and save it as an assembly? This should be a very basic capability, and either I am simply overlooking something (I very well could be - I feel like I have to be) or there is a very big flaw in the api. The comments I referred to vary from months to years old, so I would be surprised if this hadn't been addressed if it is indeed a bug.

       

      My code:


      CComPtr<ISldWorks> swApp;

      CComPtr<IModelDoc2> swModel;

      CComPtr<IModelDocExtension> swDocExt;

      CComPtr<IDispatch> swDoc;

      BSTR AsmTemplate;

      VARIANT_BOOL result;


      swApp->GetUserPreferenceStringValue(swDefaultTemplateAssembly, &AsmTemplate);

      swApp->NewDocument(AsmTemplate, 0, 0, 0, &swDoc);

      HRESULT docres = swDoc->QueryInterface(IID_IModelDoc2, (void**)&swModel);

      swModel->get_Extension(&swDocExt);

      swDocExt->SaveAs(L"Test2.SLDASM", 0, 1, NULL, &fileerror, &filewarning, &result);

       

      Thanks for your help.