public void CreateCube() { //make sure we have a part open string partTemplate = solidworks.GetUserPreferenceStringValue((int)swUserPreferenceStringValue_e.swDefaultTemplatePart); if ((partTemplate != null) && (partTemplate != "")) { IModelDoc2 modDoc = (IModelDoc2)solidworks.NewDocument(partTemplate, (int)swDwgPaperSizes_e.swDwgPaperA2size, 0.0, 0.0); modDoc.InsertSketch2(true); modDoc.SketchRectangle(0, 0, 0, .1, .1, .1, false); //Extrude the sketch IFeatureManager featMan = modDoc.FeatureManager; featMan.FeatureExtrusion(true, false, false, (int)swEndConditions_e.swEndCondBlind, (int)swEndConditions_e.swEndCondBlind, 0.1, 0.0, false, false, false, false, 0.0, 0.0, false, false, false, false, true, false, false); } else { solidworks.SendMsgToUser("There is no part template available. Please check your options and make sure there is a part template selected, or select a new part template."); } }
public void Init(ISldWorks app, IModelDoc2 model, IFeature feat) { m_App = app; m_Model = model; m_Feat = feat; m_App.SendMsgToUser($"{m_Model.GetTitle()}\\{m_Feat.Name} loaded"); }
public bool ConnectToSW(object ThisSW, int Cookie) { m_App = ThisSW as ISldWorks; m_App.SendMsgToUser("Hello World!"); return(true); }
private void butExport_Click(object sender, EventArgs e) { ExportBodies(); iswApp.SendMsgToUser("操作完成"); labStatus.Text = "完成"; }
/// <summary> /// 保存按钮执行的动作 /// </summary> private void SaveClick() { List <string> files = null; Controller.Convertor.ErrorType errors = Controller.Convertor.ErrorType.NoErros; IsInProgress = true; if (!System.IO.Directory.Exists(FilePath)) { swApp.SendMsgToUser("当前路径不存在:" + FilePath); return; } if (FilePath.Contains("-") || FileName.Contains("-")) { swApp.SendMsgToUser("-为非法字符,路径或者文件民包含-字符,请修改路径或者文件名后重新保存"); return; } try { //会堵塞UI;TODO:异步方式实现转换 var model = Controller.Convertor.DuConvertor.ConvertToglTFModel(swModel, out errors); if (model != null) { files = Controller.Convertor.DuConvertor.SaveAs(model, FilePath, FileName); } swApp.SendMsgToUser("保存完成"); if (files != null && IsOpenFile && files.Count >= 3) { System.Diagnostics.Process.Start(files[2]); } if (IsOpenFolder) { System.Diagnostics.Process.Start("explorer.exe", FilePath); } IsInProgress = false; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } // System.Diagnostics.Process.Start("ExpLore", "C:\\window"); }
public void CreateBoundingCylinderMacroFeature() { var body = m_App.IActiveDoc2.ISelectionManager.GetSelectedObject6(1, -1) as IBody2; if (body != null) { m_App.IActiveDoc2.FeatureManager.InsertComFeature <BoundingCylinderMacroFeature, BoundingCylinderMacroFeatureParams>( new BoundingCylinderMacroFeatureParams() { InputBody = body }); } else { m_App.SendMsgToUser("Please select solid body"); } }
protected override bool OnEditDefinition(ISldWorks app, IModelDoc2 model, IFeature feature) { var featData = feature.GetDefinition() as IMacroFeatureData; featData.AccessSelections(model, null); var featParams = GetParameters(feature, featData, model); featParams.DateTime = DateTime.Now; featParams.Decimal = (featParams.Decimal + 1M) * 1.002M; app.SendMsgToUser($"{nameof(featParams.Param2)} = {featParams.Param2}; {nameof(featParams.EditDefinitionsCount)} = {featParams.EditDefinitionsCount}"); featParams.EditDefinitionsCount = featParams.EditDefinitionsCount + 1; SetParameters(model, feature, featData, featParams); feature.ModifyDefinition(featData, model, null); return(true); }
public void FlyoutCommandItem1() { iSwApp.SendMsgToUser("Flyout command 1"); }
private Boolean AddMacroFeature() { IModelDoc2 moddoc; IFeatureManager FeatMgr; IFeature MacroFeature; Object paramNames; Object paramTypes; Object paramValues; string[] TparamNames = new string[3]; int[] TparamTypes = new int[3]; //Use int for 64 bit compatibility string[] TparamValues = new string[3]; IBody2 editBody; int opts; moddoc = (IModelDoc2)iSwApp.ActiveDoc; FeatMgr = (IFeatureManager)moddoc.FeatureManager; ISelectionMgr swSelMgr = (ISelectionMgr)moddoc.SelectionManager; if (swSelMgr.GetSelectedObjectCount() != 1) { iSwApp.SendMsgToUser("Please select one face or plane"); return(false); } var selFace = swSelMgr.GetSelectedObject6(1, 1); Feature[] swFeature = AddTMPBasePlaneFromSelectFace(); //Include only data that won't be available from geometry TparamNames[0] = "Size"; TparamTypes[0] = (int)swMacroFeatureParamType_e.swMacroFeatureParamTypeDouble; TparamValues[0] = newFeaturePmPage.SizeValue; //TparamNames[0] = "Width"; //TparamNames[1] = "Offset"; //TparamNames[2] = "Depth"; //TparamTypes[0] = (int)swMacroFeatureParamType_e.swMacroFeatureParamTypeDouble; //TparamTypes[1] = (int)swMacroFeatureParamType_e.swMacroFeatureParamTypeDouble; //TparamTypes[2] = (int)swMacroFeatureParamType_e.swMacroFeatureParamTypeDouble; ////Hard code the parameters for test, ////but in practice get this from Property Manager Page //TparamValues[0] = "0.01"; //Width //TparamValues[1] = "0.005"; //Offset //TparamValues[2] = "0.006"; //Depth paramNames = TparamNames; paramTypes = TparamTypes; paramValues = TparamValues; string[] icos = new string[9]; icos[0] = @"FeatureIcon.bmp"; icos[1] = @"FeatureIcon.bmp"; icos[2] = @"FeatureIcon.bmp"; icos[3] = @"FeatureIcon.bmp"; icos[4] = @"FeatureIcon.bmp"; icos[5] = @"FeatureIcon.bmp"; icos[6] = @"FeatureIcon.bmp"; icos[7] = @"FeatureIcon.bmp"; icos[8] = @"FeatureIcon.bmp"; editBody = null; opts = 0; MacroFeature = FeatMgr.InsertMacroFeature3("New-Feature", "PaineTool.NewFeature.NewFeatureHandler", null, (paramNames), (paramTypes), (paramValues), null, null, editBody, icos, opts); //var featureDif = (MacroFeatureData)MacroFeature.GetDefinition(); // featureDif.GetSelectedObjects(Filter); //var selObj = new DispatchWrapper[] { selFace }; ; //var selObjMark = new int[] { 0 }; //var views = new IView[] { null }; //featureDif.SetSelections2(selObj, selObjMark, views); //featureDif.SetSelections(selFace, 1); foreach (var item in swFeature) { // MessageBox.Show(item.Name); MacroFeature.MakeSubFeature(item); } // featureDif.ReleaseSelectionAccess(); TparamNames = null; TparamTypes = null; TparamValues = null; return(true); }
public void Unload(MacroFeatureUnloadReason_e reason) { m_App.SendMsgToUser($"{m_Model.GetTitle()}\\{m_Feat.Name} unloaded: {reason}"); }
public void OnCheckboxCheck(int id, bool status) { solidworks.SendMsgToUser("check-box checked"); }