public Inventor.AttributeSet getAttrSet <T>(T ob, string name) { AttributeSets attSets = InvDoc.Reflect.getProp <T, AttributeSets>(ob, "AttributeSets"); var ie = attSets.OfType <AttributeSet>().Where(a => a.Name.StartsWith(name)); return(ie.FirstOrDefault()); }
/// <summary> /// It generates add member using REST service by providing invalid multiple attribute sets /// </summary> /// <returns></returns> public Memberm GenerateAddMemberMultipleAttributeSetForREST() { Memberm member = new Memberm(); member.firstName = "REST_" + RandomString(6) + "_" + NameGenerator.GenerateFirstName(Gender.Male); member.lastName = "REST_" + RandomString(6) + "_" + NameGenerator.GenerateFirstName(Gender.Male); member.Username = member.firstName; member.Password = "******"; member.email = member.firstName + "@test.com"; member.cards = new List <card>(); Logger.Info(member.firstName); card vc = new card(); member.attributeSets = new List <AttributeSets>(); vc.cardNumber = new System.Random().Next(1, 9999999).ToString(); AttributeSets details = new AttributeSets(); details.memberDetails = new REST_Services.REST_Models.AttributeSet_Model(); details.memberDetails = REST_DataGenerator.GenerateMemberAttributeSet(this); vc.cardNumber = new System.Random().Next(1, 9999999).ToString(); //AttributeSets details1 = new AttributeSets(); //details1.memberDetails = new REST_Services.REST_Models.AttributeSet_Model(); //details1.memberDetails = REST_DataGenerator.GenerateMemberAttributeSet(this); member.cards.Add(vc); member.attributeSets.Add(details); //member.attributeSets.Add(details1); return(member); }
private void button5_Click(object sender, EventArgs e) { if (_invApp.Documents.Count == 0) { MessageBox.Show("Need to open an Assembly document"); return; } if (_invApp.ActiveDocument.DocumentType != DocumentTypeEnum.kAssemblyDocumentObject) { MessageBox.Show("Need to have an Assembly document active"); return; } AssemblyDocument asmDoc = (AssemblyDocument)_invApp.ActiveDocument; // Get the attribute manager for the document AttributeManager attbMan = asmDoc.AttributeManager; // Find the objects with the attributes ObjectCollection objCol = default(ObjectCollection); objCol = attbMan.FindObjects("myPartGroup", "PartGroup1", "Group1"); AttributeSets attbSets = default(AttributeSets); // Delete the attribute from the ComponentOccurrence foreach (object obj in objCol) { ComponentOccurrence compOcc = (ComponentOccurrence)obj; attbSets = compOcc.AttributeSets; attbSets["myPartGroup"].Delete(); // Make the ComponentOccurrence visible compOcc.Visible = true; } }
private void ExportAttributeSetsAsync(MixCmsContext context, IDbContextTransaction transaction) { foreach (var item in AttributeSets) { item.Fields = MixAttributeFields.UpdateViewModel.Repository.GetModelListBy(a => a.AttributeSetId == item.Id, context, transaction).Data?.OrderBy(a => a.Priority).ToList(); // Filter list reference field => Add to Export Data if not exist var refFields = item.Fields.Where(f => f.DataType == MixDataType.Reference); foreach (var field in refFields) { var refSet = AttributeSets.FirstOrDefault(m => m.Name == field.AttributeSetName); if (refSet == null) { var getSet = MixAttributeSets.ImportViewModel.Repository.GetSingleModel(m => m.Name == field.AttributeSetName, context, transaction); if (getSet.IsSucceed) { refSet = getSet.Data; refSet.IsExportData = refSet.IsExportData || item.IsExportData; AttributeSets.Add(refSet); } } else { refSet.IsExportData = refSet.IsExportData || item.IsExportData; } } // Load export data if checked and did not process if (item.IsExportData && item.Data != null) { } } }
public IList <CfgMessage> EliminateFirstFirstConflicts() { var result = new List <CfgMessage>(); foreach (var nt in new List <string>(_EnumNonTerminals())) { var rules = FillNonTerminalRules(nt); var rights = new List <IList <string> >(); foreach (var rule in rules) { rights.Add(rule.Right); } while (true) { var pfx = rights.GetLongestCommonPrefix(); if (pfx.IsNullOrEmpty()) { break; } // obv first first conflict var nnt = GetTransformId(nt); var suffixes = new List <IList <string> >(); foreach (var rule in rules) { if (rule.Right.StartsWith(pfx)) { rights.Remove(rule.Right); suffixes.Add(new List <string>(rule.Right.SubRange(pfx.Count))); result.Add(new CfgMessage(CfgErrorLevel.Message, -1, string.Format("Removing rule {0} because it is part of a first-first conflict.", rule))); Rules.Remove(rule); } } var newRule = new CfgRule(nt); newRule.Right.AddRange(pfx); newRule.Right.Add(nnt); result.Add(new CfgMessage(CfgErrorLevel.Message, -1, string.Format("Adding rule {0} to resolve first-first conflict.", newRule))); if (!Rules.Contains(newRule)) { Rules.Add(newRule); } foreach (var suffix in suffixes) { newRule = new CfgRule(nnt); newRule.Right.AddRange(suffix); result.Add(new CfgMessage(CfgErrorLevel.Message, -1, string.Format("Adding rule {0} to resolve first-first conflict.", newRule))); if (!Rules.Contains(newRule)) { Rules.Add(newRule); } } var attrs = new Dictionary <string, object>(); attrs.Add("collapse", true); AttributeSets.Add(nnt, attrs); } } return(result); }
private void ExcuteAlign(PartDocument partDoc, WorkPlane refPlane, string paraName, int coeff) { PartComponentDefinition oPartCompDef; oPartCompDef = partDoc.ComponentDefinition; WorkAxis thisFaceAxis; thisFaceAxis = oPartCompDef.WorkAxes.AddByRevolvedFace(m_thisFace, false); Double thisDist = GetDistanceBetwLineAndFace(oPartCompDef, thisFaceAxis, refPlane); thisFaceAxis.Delete(); WorkAxis withThisFaceAxis; withThisFaceAxis = oPartCompDef.WorkAxes.AddByRevolvedFace(m_withThisFace, false); Double withThisDist = GetDistanceBetwLineAndFace(oPartCompDef, withThisFaceAxis, refPlane); withThisFaceAxis.Delete(); Double differ; differ = thisDist - withThisDist; AttributeSets atr = m_thisiFeature.AttributeSets; AttributeSet abs = atr["MyAttribSet"]; Inventor.Attribute att = abs["InternalName"]; Inventor.Attribute footprint = abs["Footprint"]; string footprintCheck = footprint.Value; string thisiFeatureName = att.Value; string oParameterName = thisiFeatureName + ":" + paraName; foreach (iFeatureInput oInput in m_thisiFeature.iFeatureDefinition.iFeatureInputs) { if (oInput.Name == thisiFeatureName + ":" + paraName || oInput.Name == thisiFeatureName + ":" + paraName + ":2") { iFeatureParameterInput oParamInput; oParamInput = (iFeatureParameterInput)oInput; Double newValue = oParamInput.Parameter.Value + coeff * differ; oParamInput.Parameter.Value = newValue; } } if (footprintCheck == "Yes") { if (paraName == "y") { MoveSketch(0, coeff * differ); } else { MoveSketch(coeff * differ, 0); } } partDoc.Update2(); }
public void AttribAdd <T>(string name, T val, ValueTypeEnum VT) { attSets = doc.AttributeSets; if (attSets.NameIsUsed[name]) { AttribDelete(name); } attSet = attSets.Add(name); attSet.Add(name, VT, val); attSet = null; }
/// <summary> /// This static method will remove a specified AttributeSet from the provided Object if one exists. /// If the object is not attribute capable, the function will throw a system exception. /// </summary> /// <param name="obj">Object</param> /// <param name="attributeSetName">AttributeSet name as a string</param> public static void RemoveAttributeSet(this object obj, string attributeSetName) { dynamic temp = (dynamic)obj; if (AttributeSetExists(obj, attributeSetName)) { AttributeSets attributeSets = temp.AttributeSets; attributeSets[attributeSetName].Delete(); } }
public AttributeSet AttribSetAdd(SketchPoint ob, string nameAttSet) { attSets = ob.AttributeSets; if (attSets.NameIsUsed[nameAttSet]) { AttribDelete(nameAttSet); } attSet = attSets.Add(nameAttSet); return(attSet); }
public override void OnExecute(Document document, NameValueMap context, bool succeeded) { PartDocument oPartDoc; oPartDoc = (PartDocument)document; PartComponentDefinition oPartCompDef; oPartCompDef = oPartDoc.ComponentDefinition; AttributeSets atr = m_selectiFeature.AttributeSets; AttributeSet abs = atr["MyAttribSet"]; Inventor.Attribute att = abs["InternalName"]; Inventor.Attribute footprint = abs["Footprint"]; string name = att.Value; string footprintCheck = footprint.Value; string thisiFeatureName = name; //string oXParamName = thisiFeatureName + ":x"; //string oYParamName = thisiFeatureName + ":y"; foreach (iFeatureInput oInput in m_selectiFeature.iFeatureDefinition.iFeatureInputs) { try { if (oInput.Name == thisiFeatureName + ":x" || oInput.Name == thisiFeatureName + ":x:2") { iFeatureParameterInput oParamInput; oParamInput = (iFeatureParameterInput)oInput; Double newValue = oParamInput.Parameter.Value + m_xOffset; oParamInput.Parameter.Value = newValue; } if (oInput.Name == thisiFeatureName + ":y" || oInput.Name == thisiFeatureName + ":y:2") { iFeatureParameterInput oParamInput; oParamInput = (iFeatureParameterInput)oInput; Double newValue = oParamInput.Parameter.Value + m_yOffset; oParamInput.Parameter.Value = newValue; } } catch (Exception e) { MessageBox.Show(e.ToString()); } } if (footprintCheck == "Yes") { MoveSketch(); } oPartDoc.Update2(); //MessageBox.Show(m_selectiFeature.Name); }
public void AttribAdd <T, TVal>(T ob, string name, TVal val, ValueTypeEnum VT) { AttributeSets attSets = InvDoc.Reflect.getProp <T, AttributeSets>(ob, "AttributeSets"); if (attSets.NameIsUsed[name]) { AttribDelete(name); } attSet = attSets.Add(name); attSet.Add(name, VT, val); attSet = null; }
/// <summary> /// This static function will return boolean value indicating if the specified AttributeSet /// exists in the provided object. If the object is not attribute capable, the function /// will throw a system exception. /// </summary> /// <param name="obj">Object</param> /// <param name="attributeSetName">AttributeSet name as a string</param> public static bool AttributeSetExists(this object obj, string attributeSetName) { dynamic temp = (dynamic)obj; if (!ObjectIsAttributeCapable(obj)) { return(false); } AttributeSets attributeSets = temp.AttributeSets; return(attributeSets.NameIsUsed[attributeSetName]); }
public IList <CfgMessage> EliminateLeftRecursion() { var result = new List <CfgMessage>(); var ic = Rules.Count; for (var i = 0; i < ic; ++i) { var rule = Rules[i]; if (rule.IsDirectlyLeftRecursive) { result.Add(new CfgMessage(CfgErrorLevel.Message, -1, string.Format("Removing rule {0} because it is directly left recursive.", rule))); Rules.Remove(rule); var newId = GetTransformId(rule.Left); var col = new List <string>(); var c = rule.Right.Count; for (var j = 1; j < c; ++j) { col.Add(rule.Right[j]); } col.Add(newId); var d = new Dictionary <string, object>(); AttributeSets.Add(newId, d); d.Add("collapse", true); var newRule = new CfgRule(newId); newRule.Right.AddRange(col); result.Add(new CfgMessage(CfgErrorLevel.Message, -1, string.Format("Adding rule {1} to replace rule {0}", rule, newRule))); if (!Rules.Contains(newRule)) { Rules.Add(newRule); } var rr = new CfgRule(newId); result.Add(new CfgMessage(CfgErrorLevel.Message, -1, string.Format("Adding rule {1} to replace rule {0}", rule, rr))); if (!Rules.Contains(rr)) { Rules.Add(rr); } foreach (var r in Rules) { if (Equals(r.Left, rule.Left)) { if (!r.IsDirectlyLeftRecursive) { r.Right.Add(newId); } } } } } return(result); }
public object GetAttribute(string symbol, string name, object @default = null) { LexAttributeList l; if (AttributeSets.TryGetValue(symbol, out l)) { var i = l.IndexOf(name); if (-1 < i) { return(l[i].Value); } } return(@default); }
public Inventor.Attribute getAttrib <T>(T ob, string name) { AttributeSets attSets = InvDoc.Reflect.getProp <T, AttributeSets>(ob, "AttributeSets"); var ie = attSets.OfType <AttributeSet>().Where(a => a.Name.StartsWith(name)); foreach (var item in ie) { if (item.Count != 0) { return(item[1]); } } return(null); }
public void InsertInformation() { PartDocument oPartDocument; oPartDocument = (PartDocument)m_inventorApplication.ActiveDocument; PartComponentDefinition oPartCompDef; oPartCompDef = oPartDocument.ComponentDefinition; AttributeSets atr = m_selectiFeature.AttributeSets; int insertPlane; int insertFace; this.GetInsertFace(oPartCompDef, m_selectFace, out insertPlane, out insertFace); m_insertFace = oPartCompDef.Features.ExtrudeFeatures["拉伸1"].Faces[insertFace]; AttributeSet abs = atr["MyAttribSet"]; Inventor.Attribute internalname = abs["InternalName"]; Inventor.Attribute footprint = abs["Footprint"]; Inventor.Attribute pointX = abs["PointX"]; Inventor.Attribute pointY = abs["PointY"]; Inventor.Attribute pointZ = abs["PointZ"]; Inventor.Attribute indexname = abs["IndexName"]; m_indexname = indexname.Value; Inventor.Attribute codename = abs["CodeName"]; m_codename = codename.Value; Inventor.Attribute codenumber = abs["CodeNumber"]; m_codenumber = codenumber.Value; Inventor.Attribute angle = abs["Angle"]; m_OldAngle = angle.Value; m_InsertAngle = m_OldAngle + m_Angle; m_checkfootprint = footprint.Value; TransientGeometry oTransGeo; oTransGeo = m_inventorApplication.TransientGeometry; m_Point = oTransGeo.CreatePoint(pointX.Value, pointY.Value, pointZ.Value); Xposition = pointX.Value; //GetDistanceBtwPointandLine(m_Point,oPartCompDef.UserCoordinateSystems[insertPlane].XAxis); Yposition = pointY.Value; //GetDistanceBtwPointandLine(m_Point,oPartCompDef.UserCoordinateSystems[insertPlane].YAxis); m_iFeatureName = m_selectiFeature.Name; assembly = System.Reflection.Assembly.GetExecutingAssembly(); FileInfo asmFile = new FileInfo(assembly.Location); deFaultpath = asmFile.DirectoryName; m_filepath = deFaultpath + "\\CavityLibrary"; }
private async Task <RepositoryResponse <bool> > ImportAttributeSetDatas(string destCulture, MixCmsContext context, IDbContextTransaction transaction) { var result = new RepositoryResponse <bool>() { IsSucceed = true }; foreach (var item in AttributeSetDatas) { item.CreatedBy = CreatedBy; if (result.IsSucceed) { item.CreatedBy = CreatedBy; if (!context.MixAttributeSetData.Any(m => m.Id == item.Id && m.Specificulture == item.Specificulture)) { item.Specificulture = destCulture; item.CreatedDateTime = DateTime.UtcNow; // update new Id if not system attribute if (item.AttributeSetName.IndexOf("sys_") != 0 && dicAttributeSetIds.ContainsKey(item.AttributeSetId)) { item.AttributeSetId = dicAttributeSetIds[item.AttributeSetId]; } item.Fields = item.Fields ?? MixAttributeFields.UpdateViewModel.Repository.GetModelListBy( m => m.AttributeSetId == item.AttributeSetId, context, transaction).Data; foreach (var field in item.Fields) { field.Specificulture = destCulture; var newSet = AttributeSets.FirstOrDefault(m => m.Name == field.AttributeSetName); var newField = newSet?.Fields.FirstOrDefault(m => m.Name == field.Name); if (newField != null) { field.Id = newField.Id; field.AttributeSetId = newSet.Id; field.AttributeSetName = newSet.Name; field.CreatedDateTime = DateTime.UtcNow; } } var saveResult = await item.SaveModelAsync(true, context, transaction); ViewModelHelper.HandleResult(saveResult, ref result); } } else { break; } } return(result); }
/// <summary> /// This static function will return an Attribute's value for the provided object and Attribute name. /// If the specified attribute does not exist, an empty string is returned. If the object is not /// attribute capable, the function will throw a system exception. /// </summary> /// <param name="obj">Object</param> /// <param name="attributeSetName">AttributeSet name as a string</param> /// <param name="attributeName">Attribute name as a string</param> /// <returns></returns> public static object GetAttributeValue(this object obj, string attributeSetName, object attributeName) { dynamic temp = (dynamic)obj; if (AttributeExists(obj, attributeSetName, (string)attributeName)) { AttributeSets attributeSets = temp.AttributeSets; AttributeSet attributeSet = attributeSets[attributeSetName]; return(attributeSet[attributeName].Value); } else { return(""); } }
public void AttribDelete(string name) { try { attSets = doc.AttributeSets; attSet = attSets[name]; foreach (Inventor.Attribute att in attSet) { att.Delete(); } attSets[name].Delete(); } catch { } }
public AttributeSet AttribSetAdd(object ob, string nameAttSet) { PartFeature pf; if (ob is PartFeature) { pf = ob as PartFeature; attSets = pf.AttributeSets; if (attSets.NameIsUsed[nameAttSet]) { AttribDelete(nameAttSet); } attSet = attSets.Add(nameAttSet); return(attSet); } return(null); }
public void WriteCSharpSymbolConstantsTo(TextWriter writer, string modifiers) { if (null == modifiers) { modifiers = ""; } var names = new HashSet <string>(); writer.WriteLine(string.Concat("\t", modifiers, " const int EOS=", GetSymbolId("#EOS").ToString(), ";")); names.Add("EOS"); writer.WriteLine(string.Concat("\t", modifiers, " const int ERROR=", GetSymbolId("#ERROR").ToString(), ";")); names.Add("ERROR"); foreach (var sym in _EnumSymbols()) { IDictionary <string, object> d; object o; if (AttributeSets.TryGetValue(sym, out d) && d.TryGetValue("hidden", out o) && o is bool && (bool)o) { continue; } if (AttributeSets.TryGetValue(sym, out d) && d.TryGetValue("collapse", out o) && o is bool && (bool)o) { continue; } var sid = Convert.ToString(sym); if (_IsValidIdentifier(sid)) { string s; if (!string.IsNullOrEmpty(modifiers)) { s = string.Concat("\t", modifiers, " const int "); } else { s = string.Concat("\t", modifiers, "const int "); } var id = GetSymbolId(sym); s = string.Concat(s, CS.CreateEscapedIdentifier(sid.Replace('-', '_')), " = "); s = _GetUniqueName(names, s); names.Add(s); s = string.Concat(s, id.ToString(), ";"); writer.WriteLine(s); } } }
public void AddInformation() { PartDocument oPartDocument; oPartDocument = (PartDocument)m_inventorApplication.ActiveDocument; PartComponentDefinition oPartCompDef; oPartCompDef = oPartDocument.ComponentDefinition; AttributeSets atr = m_selectiFeature.AttributeSets; int insertPlane; int insertFace; this.GetInsertFace(oPartCompDef, m_selectFace, out insertPlane, out insertFace); m_insertFace = oPartCompDef.Features.ExtrudeFeatures["拉伸1"].Faces[insertFace]; AttributeSet abs = atr["MyAttribSet"]; Inventor.Attribute internalname = abs["InternalName"]; Inventor.Attribute footprint = abs["Footprint"]; Inventor.Attribute pointX = abs["PointX"]; Inventor.Attribute pointY = abs["PointY"]; Inventor.Attribute pointZ = abs["PointZ"]; TransientGeometry oTransGeo; oTransGeo = m_inventorApplication.TransientGeometry; m_Point = oTransGeo.CreatePoint(pointX.Value, pointY.Value, pointZ.Value); Inventor.Attribute indexname = abs["IndexName"]; m_indexname = indexname.Value; Inventor.Attribute codename = abs["CodeName"]; m_codename = codename.Value; Inventor.Attribute codenumber = abs["CodeNumber"]; m_codenumber = codenumber.Value; m_connectToaccess = new ConnectToAccess(m_filepath, m_filename, m_codename, m_indexname, m_codenumber); string sql = @"select 生产厂家 from Outlines where Outlines.标准='" + m_indexname + "'"; string [] result = new string[25]; m_connectToaccess.GetInformation(sql, "生产厂家", out result); int i = 0; while (result[i] != null) { m_insertOutlineForm.listBoxName.Items.Add(result[i]); i++; } }
public Parser ToLL1Parser(IEnumerable <Token> tokenizer = null) { var parseTable = ToLL1ParseTable(); var syms = new List <string>(); FillSymbols(syms); var nodeFlags = new int[syms.Count]; for (var i = 0; i < nodeFlags.Length; ++i) { var o = AttributeSets.GetAttribute(syms[i], "hidden", false); if (o is bool && (bool)o) { nodeFlags[i] |= 2; } o = AttributeSets.GetAttribute(syms[i], "collapsed", false); if (o is bool && (bool)o) { nodeFlags[i] |= 1; } } var attrSets = new KeyValuePair <string, object> [syms.Count][]; for (var i = 0; i < attrSets.Length; i++) { AttributeSet attrs; if (AttributeSets.TryGetValue(syms[i], out attrs)) { attrSets[i] = new KeyValuePair <string, object> [attrs.Count]; var j = 0; foreach (var attr in attrs) { attrSets[i][j] = new KeyValuePair <string, object>(attr.Key, attr.Value); ++j; } } else { attrSets[i] = null; // new KeyValuePair<string, object>[0]; } } var initCfg = new int[] { GetIdOfSymbol(StartSymbol), FillNonTerminals().Count }; return(new LL1TableParser(parseTable.ToLL1Array(syms), initCfg, syms.ToArray(), nodeFlags, attrSets, tokenizer)); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Use: Read attribute and returns its value in out parameter. // Returns true if attribute exists, false otherwise // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public static bool ReadAttribute(object target, string setName, string attName, out object value, out ValueTypeEnum type) { value = null; type = ValueTypeEnum.kIntegerType; try { AttributeSets sets = AdnInventorUtilities.GetProperty(target, "AttributeSets") as AttributeSets; if (sets == null) { return(false); } if (!sets.get_NameIsUsed(setName)) { return(false); } AttributeSet set = sets[setName]; if (!set.get_NameIsUsed(attName)) { return(false); } Inventor.Attribute att = set[attName]; type = att.ValueType; value = att.Value; return(true); } catch { return(false); } }
private async Task <RepositoryResponse <bool> > ImportAttributeSetDatas(MixCmsContext context, IDbContextTransaction transaction) { var result = new RepositoryResponse <bool>() { IsSucceed = true }; foreach (var item in AttributeSetDatas) { if (result.IsSucceed) { if (!context.MixAttributeSetData.Any(m => m.Id == item.Id && m.Specificulture == item.Specificulture)) { item.Fields = item.Fields ?? MixAttributeFields.UpdateViewModel.Repository.GetModelListBy( m => m.AttributeSetId == item.AttributeSetId, context, transaction).Data; foreach (var field in item.Fields) { var newSet = AttributeSets.FirstOrDefault(m => m.Name == field.AttributeSetName); var newField = newSet?.Fields.FirstOrDefault(m => m.Name == field.Name); if (newField != null) { field.Id = newField.Id; field.AttributeSetId = newSet.Id; field.AttributeSetName = newSet.Name; } } var saveResult = await item.SaveModelAsync(true, context, transaction); ViewModelHelper.HandleResult(saveResult, ref result); } } else { break; } } return(result); }
public static Memberm GenerateUpdateMemberForREST(Common common) { Memberm member = new Memberm(); member.birthDate = DateTime.UtcNow.AddYears(-30).ToLongTimeString(); member.email = "updateREST_" + common.RandomString(10) + "@test.com"; member.middleName = "RESTUpdateMN" + common.RandomString(10); member.changedBy = "RESTPatchUpdate"; member.Password = "******"; member.isEmployee = false; member.passwordExpireDate = DateTime.UtcNow.AddYears(30).ToLongTimeString(); member.zipCode = "96586"; member.storeLocations = new int[] { 1, 2, 3, 45 }; member.attributeSets = new List <AttributeSets>(); AttributeSets attribute = new AttributeSets(); attribute.memberDetails = GenerateMemberAttributeSet(common); member.attributeSets.Add(attribute); return(member); }
public void PortNet(iFeature oifeature) { AttributeSets atr = oifeature.AttributeSets; AttributeSet abs = atr["MyAttribSet"]; Inventor.Attribute att = abs["InternalName"]; Inventor.Attribute footprint = abs["Footprint"]; string footprintCheck = footprint.Value; Inventor.Attribute indexAttribute = abs["IndexName"]; string indexName = indexAttribute.Value; Inventor.Attribute codeNameAttribute = abs["CodeName"]; string codeName = codeNameAttribute.Value; Inventor.Attribute codeNumberAttribute = abs["CodeNumber"]; string codeNumber = codeNumberAttribute.Value; m_connectToaccess = new ConnectToAccess(deFaultpath, "CavityLibrary", codeName, indexName, codeNumber); string sql = @"select * from ComponentsDb where ComponentsDb.IndexName='" + indexName + "'"; string CavityType = m_connectToaccess.GetSingleInformation(sql, "CavityType"); if (footprintCheck == "No") { AttributeSet myPorts = atr["MyPorts"]; Inventor.Attribute AttPortNumber = myPorts["MyPortsNumber"]; int PortNumber = AttPortNumber.Value; int i = 0; string num; while (i < PortNumber) { num = (++i).ToString(); Inventor.Attribute Port = myPorts["Port" + num]; string PortNet = Port.Value; i = m_editNetForm.dataportNET.Rows.Add(); m_editNetForm.dataportNET.Rows[i].Cells[1].Value = PortNet; m_editNetForm.dataportNET.Rows[i].Cells[0].Value = ++i; } } else if (footprintCheck == "Yes" && CavityType == "二通插装孔") { AttributeSet myPorts = atr["MyPorts"]; Inventor.Attribute AttPortNumber = myPorts["MyPortsNumber"]; int PortNumber = AttPortNumber.Value; int i = 0; string num; while (i < PortNumber) { num = (++i).ToString(); Inventor.Attribute Port = myPorts["Port" + num]; string PortNet = Port.Value; i = m_editNetForm.dataportNET.Rows.Add(); m_editNetForm.dataportNET.Rows[i].Cells[1].Value = PortNet; m_editNetForm.dataportNET.Rows[i].Cells[0].Value = ++i; } Inventor.Attribute portCountAttribute = myPorts["PortsCount"]; int portCount = portCountAttribute.Value; int j = 1; while (j <= portCount) { i = m_editNetForm.dataportNET.Rows.Add(); string portName = m_connectToaccess.SelectConnectToAccess("PortName" + j.ToString()); Inventor.Attribute PortsOther = myPorts[portName]; string NetName = PortsOther.Value; m_editNetForm.dataportNET.Rows[i].Cells[1].Value = NetName; m_editNetForm.dataportNET.Rows[i].Cells[0].Value = portName; j++; } } else { AttributeSet myPorts = atr["MyPorts"]; Inventor.Attribute portCountAttribute = myPorts["PortsCount"]; int portCount = portCountAttribute.Value; int j = 1; int i = 0; while (j <= portCount) { i = m_editNetForm.dataportNET.Rows.Add(); string portName = m_connectToaccess.SelectConnectToAccess("PortName" + j.ToString()); Inventor.Attribute PortsOther = myPorts[portName]; string NetName = PortsOther.Value; m_editNetForm.dataportNET.Rows[i].Cells[1].Value = NetName; m_editNetForm.dataportNET.Rows[i].Cells[0].Value = portName; j++; } } }
public override void OnExecute(Document document, NameValueMap context, bool succeeded) { PartDocument oPartDoc; oPartDoc = (PartDocument)document; PartComponentDefinition oPartCompDef; oPartCompDef = oPartDoc.ComponentDefinition; int i = 0; while (i < 20) { if (m_deleteName[i] != null) { m_selectiFeature = oPartCompDef.Features.iFeatures[m_deleteName[i]]; AttributeSets atr = m_selectiFeature.AttributeSets; AttributeSet abs = atr["MyAttribSet"]; Inventor.Attribute att = abs["InternalName"]; Inventor.Attribute footprint = abs["Footprint"]; string footprintCheck = footprint.Value; Inventor.Attribute indexAttribute = abs["IndexName"]; string indexName = indexAttribute.Value; Inventor.Attribute codeNameAttribute = abs["CodeName"]; string codeName = codeNameAttribute.Value; Inventor.Attribute codeNumberAttribute = abs["CodeNumber"]; string codeNumber = codeNumberAttribute.Value; m_connectToaccess = new ConnectToAccess(deFaultpath + "\\CavityLibrary", "CavityLibrary", codeName, indexName, codeNumber); string sql = @"select * from ComponentsDb where ComponentsDb.IndexName='" + indexName + "'"; CavityType = m_connectToaccess.GetSingleInformation(sql, "CavityType"); string num; if (footprintCheck == "Yes" && CavityType == "板式阀通油孔") { PlanarSketch oSketchFootprint = oPartCompDef.Sketches["Footprint" + m_selectiFeature.Name]; oSketchFootprint.Delete(); AttributeSet port = atr["MyPorts"]; Inventor.Attribute portNumber = port["PortsCount"]; int portcount = portNumber.Value; int j = 1; while (j <= portcount) { string portName = m_connectToaccess.SelectConnectToAccess("PortName" + j.ToString()); oPartCompDef.Features.ExtrudeFeatures[m_selectiFeature.Name + "-" + portName].Delete(); j++; } } else if (footprintCheck == "Yes" && CavityType == "二通插装孔") { AttributeSet port = atr["MyPorts"]; Inventor.Attribute portNumber = port["MyPortsNumber"]; int portnum = portNumber.Value; int j = 1; while (j <= portnum) { num = (j).ToString(); oPartCompDef.Features.ExtrudeFeatures[m_selectiFeature.Name + "-" + num].Delete(); j++; } PlanarSketch oSketchFootprint = oPartCompDef.Sketches["Footprint" + m_selectiFeature.Name]; oSketchFootprint.Delete(); Inventor.Attribute portCountAttribute = port["PortsCount"]; int portCount = portCountAttribute.Value; j = 1; while (j <= portCount) { string portName = m_connectToaccess.SelectConnectToAccess("PortName" + j.ToString()); oPartCompDef.Features.ExtrudeFeatures[m_selectiFeature.Name + "-" + portName].Delete(); j++; } } else if ((footprintCheck == "No" && CavityType == "螺纹孔") || (footprintCheck == "No" && CavityType == "工艺油孔")) { oPartCompDef.Features.ExtrudeFeatures[m_selectiFeature.Name + "-1"].Delete(); } else { AttributeSet port = atr["MyPorts"]; Inventor.Attribute portNumber = port["MyPortsNumber"]; int portnum = portNumber.Value; int j = 1; while (j <= portnum) { num = (j).ToString(); oPartCompDef.Features.ExtrudeFeatures[m_selectiFeature.Name + "-" + num].Delete(); j++; } } m_selectiFeature.Delete(); if (m_outlineDelete) { PlanarSketch oSketchOutline = oPartCompDef.Sketches["Footprint" + m_selectiFeature.Name]; oSketchOutline.Delete(); } } i++; } MessageBox.Show("元件删除成功"); }
private void ProcessAttributeSetsAsync(MixCmsContext context, IDbContextTransaction transaction) { foreach (var item in AttributeSets) { item.Fields = MixAttributeFields.UpdateViewModel.Repository.GetModelListBy(a => a.AttributeSetId == item.Id, context, transaction).Data?.OrderBy(a => a.Priority).ToList(); // Filter list reference field => Add to Export Data if not exist var refFields = item.Fields.Where(f => f.DataType == MixEnums.MixDataType.Reference); foreach (var field in refFields) { var refSet = AttributeSets.FirstOrDefault(m => m.Name == field.AttributeSetName); if (refSet == null) { var getSet = MixAttributeSets.ImportViewModel.Repository.GetSingleModel(m => m.Name == field.AttributeSetName, context, transaction); if (getSet.IsSucceed) { refSet = getSet.Data; // Load ref data if export parent Data if (item.IsExportData) { var refData = MixAttributeSetDatas.ImportViewModel.Repository.GetModelListBy( a => a.Specificulture == Specificulture && a.AttributeSetId == refSet.Id, context, transaction) .Data?.OrderBy(a => a.Priority).ToList(); if (refData != null) { AttributeSetDatas.AddRange(refData); } } AttributeSets.Add(getSet.Data); } } else { refSet.IsExportData = refSet.IsExportData || item.IsExportData; if (item.IsExportData) { refSet.Data = refSet.Data ?? MixAttributeSetDatas.ImportViewModel.Repository.GetModelListBy( a => a.Specificulture == Specificulture && a.AttributeSetId == refSet.Id, context, transaction) .Data?.OrderBy(a => a.Priority).ToList(); } } } // Load export data if checked and did not process if (item.IsExportData) { var data = item.Data ?? MixAttributeSetDatas.ImportViewModel.Repository.GetModelListBy( a => a.Specificulture == Specificulture && a.AttributeSetId == item.Id, context, transaction) .Data?.OrderBy(a => a.Priority).ToList(); if (data != null) { AttributeSetDatas.AddRange(data); } foreach (var d in item.Data) { var getRelatedData = MixRelatedAttributeDatas.ReadViewModel.Repository.GetModelListBy( m => m.ParentId == d.Id && d.Specificulture == Specificulture); if (getRelatedData.IsSucceed) { RelatedData.AddRange(getRelatedData.Data); } } } } }
public override void OnExecute(Document document, NameValueMap context, bool succeeded) { PartDocument oPartDoc = (PartDocument)m_inventorApplication.ActiveDocument; SelectSet oSelectSet = oPartDoc.SelectSet; PartComponentDefinition oPartCompDef; oPartCompDef = oPartDoc.ComponentDefinition; try { int Portname = int.Parse(m_selectportName); string portEditName; portEditName = m_selectiFeature.Name + "-" + m_selectportName; ExtrudeFeature portFaceExtru; portFaceExtru = oPartCompDef.Features.ExtrudeFeatures[portEditName]; Asset asset = null; foreach (Asset asset1 in oPartDoc.Assets) { if (asset1.DisplayName == m_netName) { asset = asset1; } } portFaceExtru.Appearance = asset; string coneEditName; if (m_selectportName == "1") { coneEditName = m_selectiFeature.Name + "-" + m_selectportName + "cone"; ExtrudeFeature coneFaceExtru; coneFaceExtru = oPartCompDef.Features.ExtrudeFeatures[coneEditName]; coneFaceExtru.Appearance = asset; } AttributeSets Ports = m_selectiFeature.AttributeSets; AttributeSet myPorts = Ports["MyPorts"]; Inventor.Attribute Port = myPorts["Port" + m_selectportName]; Port.Value = m_netName; } catch { string portEditName; portEditName = m_selectiFeature.Name + "-" + m_selectportName; ExtrudeFeature portFaceExtru; portFaceExtru = oPartCompDef.Features.ExtrudeFeatures[portEditName]; Asset asset = null; foreach (Asset asset1 in oPartDoc.Assets) { if (asset1.DisplayName == m_netName) { asset = asset1; } } portFaceExtru.Appearance = asset; string coneEditName; coneEditName = m_selectiFeature.Name + "-" + m_selectportName + "cone"; ExtrudeFeature coneFaceExtru; coneFaceExtru = oPartCompDef.Features.ExtrudeFeatures[coneEditName]; coneFaceExtru.Appearance = asset; AttributeSets Ports = m_selectiFeature.AttributeSets; AttributeSet myPorts = Ports["MyPorts"]; Inventor.Attribute Port = myPorts[m_selectportName]; Port.Value = m_netName; } }