public static void AddModelsFromFolderM(List <string> modelsPaths) { try{ foreach (string modelPath in modelsPaths) { SldWorks swApp = Activator.CreateInstance(Type.GetTypeFromProgID("SldWorks.Application")) as SldWorks; swApp.Visible = false; swApp.OpenDocSilent(modelPath, (int)swDocumentTypes_e.swDocPART, ref fileerror); ModelDoc2 swModel; swModel = swApp.ActiveDoc; if (swModel != null) { swModel.Visible = false; } double[] modelXYZ = SolidWorksUtil.GetModelXYZ((PartDoc)swModel); DataBaseUtil.AddModelToDataBase(swModel.GetTitle(), Convert.ToSingle(modelXYZ[0]), Convert.ToSingle(modelXYZ[1]), Convert.ToSingle(modelXYZ[2]), AddModelsFromFolder.privateModelCheckBox.Checked, Utils.ModelToBytes(swModel)); swApp.CloseDoc(swModel.GetTitle()); } } catch (Exception e) { MessageBox.Show(e.Message, "addModelsFromFolder()", MessageBoxButtons.OK); return; } MessageBox.Show("Models were added!", "Search 3D Modelsz", MessageBoxButtons.OK); }
public static void AddModelToDataBase() { ModelDoc2 swModel = default(ModelDoc2); swModel = (ModelDoc2)AddModel.swAppAddModel.ActiveDoc; if (DataBaseUtil.AddModelToDataBase(AddModel.nameGetModel.Text, Single.Parse(AddModel.heighGetModel.Text), Single.Parse(AddModel.lengthGetModel.Text), Single.Parse(AddModel.widthGetModel.Text), AddModel.privateModelCheckBox.Checked, Utils.ModelToBytes(swModel))) { MessageBox.Show("Model was added!", "Search 3D Models", MessageBoxButtons.OK); } }