private void insertXport(PartDocument oPartDoc, PartComponentDefinition oPartCompDef) { string oInputName; PartFeatures oFeatures; oFeatures = oPartCompDef.Features; getInsertFace(oPartCompDef); iFeatureDefinition oiFeatureDef; oiFeatureDef = oFeatures.iFeatures.CreateiFeatureDefinition(filepath + "\\" + codenumber + "Cavity.ide"); foreach (iFeatureInput oInput in oiFeatureDef.iFeatureInputs) { if (oInput.Name == "放置平面" || oInput.Name == "x轴" || oInput.Name == "y轴" || oInput.Name == "y" || oInput.Name == "x") { switch (oInput.Name) { case "放置平面": iFeatureSketchPlaneInput oPlaneInput; oPlaneInput = (iFeatureSketchPlaneInput)oInput; oPlaneInput.PlaneInput = m_insertFace; break; case "x轴": iFeatureEntityInput oInputXAxis; oInputXAxis = (iFeatureEntityInput)oInput; oInputXAxis.Entity = oPartCompDef.UserCoordinateSystems[m_insertPlane].XAxis; break; case "y轴": iFeatureEntityInput oInputYAxis; oInputYAxis = (iFeatureEntityInput)oInput; oInputYAxis.Entity = oPartCompDef.UserCoordinateSystems[m_insertPlane].YAxis; break; case "y": iFeatureParameterInput oInputx; oInputx = (iFeatureParameterInput)oInput; oInputx.Value = xdistance; break; case "x": iFeatureParameterInput oInputy; oInputy = (iFeatureParameterInput)oInput; oInputy.Value = ydistance; break; } } else { oInputName = oInput.Name; iFeatureParameterInput oParameXInput; oParameXInput = (iFeatureParameterInput)oInput; m_connectToaccess = new ConnectToAccess(filepath, "CavityLibrary", codename, indexname, codenumber); oParameXInput.Expression = m_connectToaccess.SelectConnectToAccess(oInputName); } } iFeature oiFeature; oiFeature = oFeatures.iFeatures.Add(oiFeatureDef); AttributeSets oAttributeSets; oAttributeSets = oiFeature.AttributeSets; AttributeSet oAttributeSet; oAttributeSet = oAttributeSets.Add("MyAttribSet", false); Inventor.Attribute oPlaneAttrib; oPlaneAttrib = oAttributeSet.Add("InternalName", ValueTypeEnum.kStringType, oiFeature.Name); Inventor.Attribute oFootprintAttrib; oFootprintAttrib = oAttributeSet.Add("Footprint", ValueTypeEnum.kStringType, "No"); Inventor.Attribute IndexNameAttrib; IndexNameAttrib = oAttributeSet.Add("IndexName", ValueTypeEnum.kStringType, indexname); Inventor.Attribute CodeNameAttrib; CodeNameAttrib = oAttributeSet.Add("CodeName", ValueTypeEnum.kStringType, codename); Inventor.Attribute CodeNumberAttrib; CodeNumberAttrib = oAttributeSet.Add("CodeNumber", ValueTypeEnum.kStringType, codenumber); Double PortDepth1 = GetValueFromExpression(m_connectToaccess.SelectConnectToAccess("PortDepth1")); Double Depth0 = GetValueFromExpression(m_connectToaccess.SelectConnectToAccess("Depth0")); oAttributeSet.Add("MyPortsNumber", ValueTypeEnum.kIntegerType, 1); oAttributeSet.Add("Port1", ValueTypeEnum.kStringType, "NET1"); oiFeature.Name = XPortID; Drowport(oiFeature, m_insertFace, PortDepth1, Depth0, "NET1"); ShowPortColor(); }
public void insertBoltHolesTwo() { NameValueMap cont; cont = m_inventorApplication.TransientObjects.CreateNameValueMap(); string oInputName; PartDocument oPartDocument; oPartDocument = (PartDocument)m_inventorApplication.ActiveDocument; PartComponentDefinition oPartCompDef; oPartCompDef = oPartDocument.ComponentDefinition; Face oSelectFace; oSelectFace = m_selsectFace; PartFeatures oFeatures; oFeatures = oPartCompDef.Features; iFeatureDefinition oiFeatureDef; oiFeatureDef = oFeatures.iFeatures.CreateiFeatureDefinition(filepath + "\\1101Two.ide"); //double offest = GetValueFromExpression(tb1.Text); Edge edge4 = oSelectFace.Edges[4]; Edge edge2 = oSelectFace.Edges[2]; Edge edge1 = oSelectFace.Edges[1]; Edge edge3 = oSelectFace.Edges[3]; double disx = m_inventorApplication.MeasureTools.GetMinimumDistance(edge4, edge2, InferredTypeEnum.kNoInference, InferredTypeEnum.kNoInference, cont) - offset; double disy = m_inventorApplication.MeasureTools.GetMinimumDistance(edge1, edge3, InferredTypeEnum.kNoInference, InferredTypeEnum.kNoInference, cont) - offset; int i = JudgeFaceUcs(oSelectFace); foreach (iFeatureInput oInput in oiFeatureDef.iFeatureInputs) { if (oInput.Name == "放置平面" || oInput.Name == "dx1" || oInput.Name == "dy1" || oInput.Name == "dx2" || oInput.Name == "dy2" || oInput.Name == "x轴" || oInput.Name == "y轴") { switch (oInput.Name) { case "放置平面": iFeatureSketchPlaneInput oPlaneInput; oPlaneInput = (iFeatureSketchPlaneInput)oInput; oPlaneInput.PlaneInput = oSelectFace; break; case "x轴": iFeatureEntityInput oInputXAxis; oInputXAxis = (iFeatureEntityInput)oInput; oInputXAxis.Entity = oPartCompDef.UserCoordinateSystems[i].XAxis; if (i == 3 || i == 4) { oInputXAxis.Entity = oPartCompDef.UserCoordinateSystems[i].XAxis; } else if (i == 5) { oInputXAxis.Entity = oSelectFace.Edges[2]; } else { oInputXAxis.Entity = oSelectFace.Edges[1]; } break; case "y轴": iFeatureEntityInput oInputYAxis; oInputYAxis = (iFeatureEntityInput)oInput; oInputYAxis.Entity = oPartCompDef.UserCoordinateSystems[i].YAxis; if (i == 3 || i == 4) { oInputYAxis.Entity = oPartCompDef.UserCoordinateSystems[i].YAxis; } else if (i == 5) { oInputYAxis.Entity = oSelectFace.Edges[3]; } else { oInputYAxis.Entity = oSelectFace.Edges[2]; } break; case "dx1": iFeatureParameterInput oInputx; oInputx = (iFeatureParameterInput)oInput; oInputx.Value = offset; break; case "dy1": iFeatureParameterInput oInputy; oInputy = (iFeatureParameterInput)oInput; oInputy.Value = offset; break; case "dx2": iFeatureParameterInput oInputdisy; oInputdisy = (iFeatureParameterInput)oInput; if (i == 3 || i == 5) { oInputdisy.Value = disx; } else { oInputdisy.Value = disy; } break; case "dy2": iFeatureParameterInput oInputdisx; oInputdisx = (iFeatureParameterInput)oInput; if (i == 3 || i == 5) { oInputdisx.Value = disy; } else { oInputdisx.Value = disx; } break; } } else { oInputName = oInput.Name; iFeatureParameterInput oParameXInput; oParameXInput = (iFeatureParameterInput)oInput; m_connectToaccess = new ConnectToAccess(filepath, filename, codename, indexname, codenumber); oParameXInput.Expression = m_connectToaccess.SelectConnectToAccess(oInputName); } } iFeature oiFeature; oiFeature = oFeatures.iFeatures.Add(oiFeatureDef); WriteAttribute(oiFeature, "No"); oiFeature.Name = IDName; }
private void btnsave_Click(object sender, EventArgs e) { IndexName = cmbIndexName.Text.ToString(); codenumber = combcodenumber.Text.ToString(); codename = tb1.Text.ToString(); string sql = "insert into " + IndexName + "(索引编号,编码) values('" + codenumber + "','" + codename + "')"; m_connectToAccess = new ConnectToAccess(deFaultpath, "CavityLibrary"); if (m_connectToAccess.InsertInformation(sql)) { foreach (Control ctr in this.groBcavitydim.Controls) //输入孔的尺寸参数 { if (ctr is TextBox) { //TextBox ctr1=new ctr as TextBox; if ((ctr as TextBox).Text.Length != 0) { string sqlupdate = "update " + IndexName + " set " + (ctr as TextBox).Name + "='" + (ctr as TextBox).Text + "' where 编码 ='" + codename + "'"; if (m_connectToAccess.UpdateInformation(sqlupdate)) { } ; } } } foreach (Control ctr in this.groBThread.Controls) //输入螺纹的参数信息 { if (ctr is TextBox) { //TextBox ctr1=new ctr as TextBox; if ((ctr as TextBox).Text.Length != 0) { string sqlupdate = "update " + IndexName + " set " + (ctr as TextBox).Name + "='" + (ctr as TextBox).Text + "' where 编码 ='" + codename + "'"; if (m_connectToAccess.UpdateInformation(sqlupdate)) { } ; } } } foreach (Control ctr in this.groBcarvalve.Controls) //输入油孔的参数信息 { if (ctr is TextBox) { //TextBox ctr1=new ctr as TextBox; if ((ctr as TextBox).Text.Length != 0) { string sqlupdate = "update " + IndexName + " set " + (ctr as TextBox).Name + "='" + (ctr as TextBox).Text + "' where 编码 ='" + codename + "'"; if (m_connectToAccess.UpdateInformation(sqlupdate)) { } ; } } } if (groBfacedim.Enabled == true) //输入安装面的油孔位置信息 { int i = 0; while (i < combcodenumber.Items.Count && combcodenumber.Text.ToString() != combcodenumber.Items[i].ToString()) { i++; } if (combcodenumber.Text.ToString() == combcodenumber.Items[i].ToString()) { EditGrouFaceDim(); } else { AddNewGrouFaceDim(); } } MessageBox.Show("插入新元件成功"); } }