private InvAssets(Inventor.Assets invAssets) { InternalAssets = invAssets; }
public static InvAssets ByInvAssets(Inventor.Assets invAssets) { return(new InvAssets(invAssets)); }
public void AddOrRemoveFromGroup(bool add) { 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 = default(AssemblyDocument); asmDoc = (AssemblyDocument)_invApp.ActiveDocument; if (asmDoc.SelectSet.Count == 0) { MessageBox.Show("Need to select a Part or Sub Assembly"); return; } SelectSet selSet = default(SelectSet); selSet = asmDoc.SelectSet; Inventor.Assets colour = asmDoc.Assets; try { ComponentOccurrence compOcc = default(ComponentOccurrence); object obj = null; foreach (object obj_loopVariable in selSet) { obj = obj_loopVariable; compOcc = (ComponentOccurrence)obj; System.Diagnostics.Debug.Print(compOcc.Name); AttributeSets attbSets = compOcc.AttributeSets; if (add) { // Add the attributes to the ComponentOccurrence if (!attbSets.NameIsUsed["myPartGroup"]) { AttributeSet attbSet = attbSets.Add("myPartGroup"); Inventor.Attribute attb = attbSet.Add("PartGroup1", ValueTypeEnum.kStringType, "Group1"); Inventor.Asset asset = asmDoc.Assets["Red"]; compOcc.Appearance = asset; } } else { // Delete the attributes to the ComponentOccurrence if (attbSets.NameIsUsed["myPartGroup"]) { attbSets["myPartGroup"].Delete(); } } //compOcc.Visible = False } } catch (Exception ex) { MessageBox.Show("Is the selected item a Component?"); MessageBox.Show(ex.ToString()); return; } }