public static void Save(AssemblyDocument document, FieldProperties fieldProps, List <PropertySet> propertySets) { Inventor.PropertySets inventorPropertySets = document.PropertySets; try { Inventor.PropertySet p = GetPropertySet(inventorPropertySets, "synthesisField"); // Field Properties SetProperty(p, "spawnpoints", JsonConvert.SerializeObject(fieldProps.spawnpoints)); SetProperty(p, "gamepieces", JsonConvert.SerializeObject(fieldProps.gamepieces)); // Property Sets SetProperty(p, "propertySets", JsonConvert.SerializeObject(propertySets, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto })); // Occurrences for (int i = 0; i < propertySets.Count; i++) { var tabPage = (Components.ComponentPropertiesTabPage)Program.MAINWINDOW.GetPropertySetsTabControl().TabPages[propertySets[i].PropertySetID]; if (tabPage != null) { Components.InventorTreeView treeView = tabPage.ChildForm.inventorTreeView; List <string> occurrences = new List <string>(); foreach (TreeNode node in treeView.Nodes) { CreateOccurrenceList(node, "", occurrences); } SetProperty(p, "propertySets." + propertySets[i].PropertySetID + ".occurrences", JsonConvert.SerializeObject(occurrences)); } else { SetProperty(p, "propertySets." + propertySets[i].PropertySetID + ".occurrences", "[]"); } } } catch (Exception e) { throw new FailedToSaveException(e); } }
private static Inventor.PropertySet GetPropertySet(Inventor.PropertySets sets, string name, bool createIfDoesNotExist = true) { foreach (Inventor.PropertySet set in sets) { if (set.Name == name) { return(set); } } if (createIfDoesNotExist) { return(sets.Add(name)); } else { return(null); } }
public static void Load(AssemblyDocument document, out FieldProperties fieldProps, out List <PropertySet> propertySets, out Dictionary <string, List <string> > occurrencePropSets) { Inventor.PropertySets inventorPropertySets = document.PropertySets; try { Inventor.PropertySet p = GetPropertySet(inventorPropertySets, "synthesisField"); // Field Properties BXDVector3[] spawnpoints = JsonConvert.DeserializeObject <BXDVector3[]>(GetProperty(p, "spawnpoints", "[]")); if (spawnpoints == null) { spawnpoints = new BXDVector3[0]; } Gamepiece[] gamepieces = JsonConvert.DeserializeObject <Gamepiece[]>(GetProperty(p, "gamepieces", "[]")); if (gamepieces == null) { gamepieces = new Gamepiece[0]; } fieldProps = new FieldProperties(spawnpoints, gamepieces); // Property Sets propertySets = JsonConvert.DeserializeObject <List <PropertySet> >(GetProperty(p, "propertySets", "[]"), new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto }); // Occurrences occurrencePropSets = new Dictionary <string, List <string> >(); for (int i = 0; i < propertySets.Count(); i++) { occurrencePropSets.Add(propertySets[i].PropertySetID, JsonConvert.DeserializeObject <List <string> >(GetProperty(p, "propertySets." + propertySets[i].PropertySetID + ".occurrences", "[]"))); } } catch (Exception e) { throw new FailedToLoadException(e); } }
private InvPropertySets(Inventor.PropertySets invPropertySets) { InternalPropertySets = invPropertySets; }
public static InvPropertySets ByInvPropertySets(Inventor.PropertySets invPropertySets) { return(new InvPropertySets(invPropertySets)); }