static void ReportRelation(SolidEdgeAssembly.PathRelation3d relation3d, SolidEdgeFramework.ObjectType objectType) { Console.WriteLine("Index: {0} ({1})", relation3d.Index, objectType); try { Console.WriteLine("DetailedStatus: {0}", relation3d.DetailedStatus); } catch { } try { Console.WriteLine("Status: {0}", relation3d.Status); } catch { } try { Console.WriteLine("Suppress: {0}", relation3d.Suppress); } catch { } Console.WriteLine(); }
static void ReportRelations3d(SolidEdgeAssembly.Relations3d relations3d) { SolidEdgeAssembly.GroundRelation3d groundRelation3d = null; SolidEdgeAssembly.AxialRelation3d axialRelation3d = null; SolidEdgeAssembly.PlanarRelation3d planarRelation3d = null; for (int i = 1; i <= relations3d.Count; i++) { object relation3d = relations3d.Item(i); // GetInteropType() is a custom method extension! Type t = relation3d.GetInteropType(); Console.WriteLine("Relations3d[{0}] is of type '{1}'.", i, t); // Determine the ObjectType. SolidEdgeFramework.ObjectType relationType = (SolidEdgeFramework.ObjectType)relation3d.GetType().InvokeMember("Type", System.Reflection.BindingFlags.GetProperty, null, relation3d, null); switch (relationType) { case SolidEdgeFramework.ObjectType.igGroundRelation3d: groundRelation3d = (SolidEdgeAssembly.GroundRelation3d)relation3d; break; case SolidEdgeFramework.ObjectType.igAxialRelation3d: axialRelation3d = (SolidEdgeAssembly.AxialRelation3d)relation3d; break; case SolidEdgeFramework.ObjectType.igPlanarRelation3d: planarRelation3d = (SolidEdgeAssembly.PlanarRelation3d)relation3d; break; default: break; } } }
public PartProperty(object property, SolidEdgeFramework.UnitsOfMeasure unitesOfMeasure) { // TODO: Fix error in ST9 with UnitsType not accessible /** * try { * this.unitType = dimension.UnitsType; * } catch (Exception ex) { * log.Error(ex.Message); * } **/ try { Type type = property.GetType(); SolidEdgeFramework.ObjectType objectType = (SolidEdgeFramework.ObjectType)type.InvokeMember("Type", System.Reflection.BindingFlags.GetProperty, null, property, null); switch (objectType) { case SolidEdgeFramework.ObjectType.igDimension: SolidEdgeFrameworkSupport.Dimension dimension = (SolidEdgeFrameworkSupport.Dimension)property; this.Name = dimension.DisplayName.ToString(); this.Value = GetValueofCurrentMeasure(unitesOfMeasure, this.UnitType, dimension.Value); this.Units = GetUnitsOfCurrentMeasure(unitesOfMeasure, this.UnitType, dimension.Value); Marshal.FinalReleaseComObject(dimension); break; // Currently only supporting dimension properties case SolidEdgeFramework.ObjectType.igVariable: SolidEdgeFramework.variable variable = (SolidEdgeFramework.variable)property; this.Name = variable.DisplayName.ToString(); this.Value = GetValueofCurrentMeasure(unitesOfMeasure, this.UnitType, variable.Value); this.Units = GetUnitsOfCurrentMeasure(unitesOfMeasure, this.UnitType, variable.Value); Marshal.FinalReleaseComObject(variable); break; } } catch (Exception ex) { log.Error(ex.Message); } }
void ISEAssemblyRecomputeEvents_BeforeDelete(object theDocument, object Object, SolidEdgeFramework.ObjectType Type) { LogEvent(MethodInfo.GetCurrentMethod(), new object[] { theDocument, Object, Type, Type }); }
void ISEAssemblyRecomputeEvents_AfterModify(object theDocument, object Object, SolidEdgeFramework.ObjectType Type, SolidEdgeFramework.seAssemblyEventConstants ModifyType) { LogEvent(MethodInfo.GetCurrentMethod(), new object[] { theDocument, Object, Type, ModifyType }); }
void ISEAssemblyChangeEvents_BeforeChange(object theDocument, object Object, SolidEdgeFramework.ObjectType Type, SolidEdgeFramework.seAssemblyChangeEventsConstants ChangeType) { LogEvent(MethodInfo.GetCurrentMethod(), new object[] { theDocument, Object, Type, ChangeType }); }
static void ReportRelation(SolidEdgeAssembly.TangentRelation3d relation3d, SolidEdgeFramework.ObjectType objectType) { Console.WriteLine("Index: {0} ({1})", relation3d.Index, objectType); try { Console.WriteLine("DetailedStatus: {0}", relation3d.DetailedStatus); } catch { } try { Console.WriteLine("HalfSpacePositive: {0}", relation3d.HalfSpacePositive); } catch { } try { Console.WriteLine("Offset: {0}", relation3d.Offset); } catch { } try { Console.WriteLine("RangedOffset: {0}", relation3d.RangedOffset); } catch { } try { Console.WriteLine("RangeHigh: {0}", relation3d.RangeHigh); } catch { } try { Console.WriteLine("RangeLow: {0}", relation3d.RangeLow); } catch { } try { Console.WriteLine("Status: {0}", relation3d.Status); } catch { } try { Console.WriteLine("Suppress: {0}", relation3d.Suppress); } catch { } Console.WriteLine(); }
static void ReportRelation(SolidEdgeAssembly.SegmentTangentRelation3d relation3d, SolidEdgeFramework.ObjectType objectType) { Console.WriteLine("Index: {0} ({1})", relation3d.Index, objectType); try { Console.WriteLine("Status: {0}", relation3d.Status); } catch { } Console.WriteLine(); }
static void ReportRelation(SolidEdgeAssembly.SegmentAngularRelation3d relation3d, SolidEdgeFramework.ObjectType objectType) { Console.WriteLine("Index: {0} ({1})", relation3d.Index, objectType); try { Console.WriteLine("AngleCounterclockwise: {0}", relation3d.AngleCounterclockwise); } catch { } try { Console.WriteLine("AngleToPositiveDirection: {0}", relation3d.AngleToPositiveDirection); } catch { } try { Console.WriteLine("Status: {0}", relation3d.Status); } catch { } Console.WriteLine(); }
static void ReportRelation(SolidEdgeAssembly.PlanarRelation3d relation3d, SolidEdgeFramework.ObjectType objectType) { Console.WriteLine("Index: {0} ({1})", relation3d.Index, objectType); try { Console.WriteLine("DetailedStatus: {0}", relation3d.DetailedStatus); } catch { } try { Console.WriteLine("FixedOffset: {0}", relation3d.FixedOffset); } catch { } try { Console.WriteLine("NormalsAligned: {0}", relation3d.NormalsAligned); } catch { } try { Console.WriteLine("Offset: {0}", relation3d.Offset); } catch { } try { Console.WriteLine("RangedOffset: {0}", relation3d.RangedOffset); } catch { } try { Console.WriteLine("RangeHigh: {0}", relation3d.RangeHigh); } catch { } try { Console.WriteLine("RangeLow: {0}", relation3d.RangeLow); } catch { } try { Console.WriteLine("Status: {0}", relation3d.Status); } catch { } try { Console.WriteLine("Suppress: {0}", relation3d.Suppress); } catch { } Console.WriteLine(); }
static void ReportRelation(SolidEdgeAssembly.AxialRelation3d relation3d, SolidEdgeFramework.ObjectType objectType) { Console.WriteLine("Index: {0} ({1})", relation3d.Index, objectType); try { Console.WriteLine("DetailedStatus: {0}", relation3d.DetailedStatus); } catch { } try { Console.WriteLine("FixedParallelOffset: {0}", relation3d.FixedParallelOffset); } catch { } try { Console.WriteLine("FixedRotate: {0}", relation3d.FixedRotate); } catch { } try { Console.WriteLine("Offset: {0}", relation3d.Offset); } catch { } try { Console.WriteLine("Orientation: {0}", relation3d.Orientation); } catch { } try { Console.WriteLine("ParallelOffset: {0}", relation3d.ParallelOffset); } catch { } try { Console.WriteLine("RangedOffset: {0}", relation3d.RangedOffset); } catch { } try { Console.WriteLine("RangeHigh: {0}", relation3d.RangeHigh); } catch { } try { Console.WriteLine("RangeLow: {0}", relation3d.RangeLow); } catch { } try { Console.WriteLine("Status: {0}", relation3d.Status); } catch { } try { Console.WriteLine("Suppress: {0}", relation3d.Suppress); } catch { } Console.WriteLine(); }
static void ReportRelation(SolidEdgeAssembly.AngularRelation3d relation3d, SolidEdgeFramework.ObjectType objectType) { Console.WriteLine("Index: {0} ({1})", relation3d.Index, objectType); try { Console.WriteLine("Angle: {0}", relation3d.Angle); } catch { } try { Console.WriteLine("DetailedStatus: {0}", relation3d.DetailedStatus); } catch { } try { Console.WriteLine("RangedAngle: {0}", relation3d.RangedAngle); } catch { } try { Console.WriteLine("RangeHigh: {0}", relation3d.RangeHigh); } catch { } try { Console.WriteLine("RangeLow: {0}", relation3d.RangeLow); } catch { } try { Console.WriteLine("Status: {0}", relation3d.Status); } catch { } try { Console.WriteLine("Suppress: {0}", relation3d.Suppress); } catch { } Console.WriteLine(); }
private void OkButton_Click(object sender, EventArgs e) { Log.Debug("assemblyDocument: " + this.Document.Name + " path: " + this.Document.Path); if (string.IsNullOrEmpty(this.Document.Path)) { MessageBox.Show("You must save the current assembly before adding parts"); } else { SolidEdgePart.PartDocument partDocument = (SolidEdgePart.PartDocument) this.Document.Application.Documents.Open(this._filePath, 0x00000008);//, "8"); this.Document.Application.DoIdle(); Log.Debug("partDocument: " + partDocument.Name); // Get file properties of the partDocument SolidEdgeFramework.Properties objProperties = ((SolidEdgeFramework.PropertySets)partDocument.Properties).Item("Custom"); // Handles naming convention when it is not followed int length = partDocument.Name.IndexOf(".par"); if (length <= 0) { Log.Warn("selected file is not a Part Document"); length = partDocument.Name.Length; } string fileName = partDocument.Name.Substring(0, length); string[] variableValuesArray = new string[this._settings.getNumberOfVariables()]; foreach (PartProperty partProperty in this.partPropertyBindingSource) { if (this._settings.isVariableDefined(partProperty.Name)) { // Get a reference to the Variables collection. SolidEdgeFramework.Variables variables = (SolidEdgeFramework.Variables)partDocument.Variables; // Get a reference to the variableList. SolidEdgeFramework.VariableList variableList = (SolidEdgeFramework.VariableList)variables.Query(partProperty.Name, SolidEdgeConstants.VariableNameBy.seVariableNameByBoth, SolidEdgeConstants.VariableVarType.SeVariableVarTypeBoth, false); foreach (var property in variableList) { try { Type type = property.GetType(); SolidEdgeFramework.ObjectType objectType = (SolidEdgeFramework.ObjectType)type.InvokeMember("Type", System.Reflection.BindingFlags.GetProperty, null, property, null); switch (objectType) { case SolidEdgeFramework.ObjectType.igDimension: SolidEdgeFrameworkSupport.Dimension dimension = (SolidEdgeFrameworkSupport.Dimension)property; dimension.Value = partProperty.GetSolidEdgeStoredValue(partDocument.UnitsOfMeasure); Marshal.FinalReleaseComObject(dimension); break; case SolidEdgeFramework.ObjectType.igVariable: SolidEdgeFramework.variable variable = (SolidEdgeFramework.variable)property; variable.Value = partProperty.GetSolidEdgeStoredValue(partDocument.UnitsOfMeasure); Marshal.FinalReleaseComObject(variable); break; } Log.Debug(this._settings.getVariableIndex(partProperty.Name) + " >= " + variableValuesArray.Length); if (this._settings.getVariableIndex(partProperty.Name) >= variableValuesArray.Length) { Array.Resize <string>(ref variableValuesArray, this._settings.getVariableIndex(partProperty.Name) + 1); } variableValuesArray[this._settings.getVariableIndex(partProperty.Name)] = partProperty.Value + " " + partProperty.Units; // Update file property try { // TODO: Fix exception when partProperty.Name is not defined in objProperties.Item SolidEdgeFramework.Property objProperty = objProperties.Item(partProperty.Name); objProperty.set_Value(partProperty.Value.ToString()); Marshal.FinalReleaseComObject(objProperty); } catch (Exception ex) { Log.Warn("no file property exists for " + partProperty.Name + " | " + ex.Message); } } catch (Exception ex) { Log.Error(ex.Message); } } Marshal.FinalReleaseComObject(variables); Marshal.FinalReleaseComObject(variableList); } } objProperties.Save(); Marshal.FinalReleaseComObject(objProperties); // Remove invalid fileName characters fileName = string.Join("", fileName.Split(Path.GetInvalidFileNameChars())); variableValuesArray = variableValuesArray.Where(c => c != null).ToArray(); fileName += "-" + string.Join(this._settings.getFileNameSeparator(), variableValuesArray); Log.Debug("fileName: " + fileName); string fullPathName = this.Document.Path; string assemblyPartFolderName = _settings.getAssemblyPartFolderName(); if (assemblyPartFolderName != null & assemblyPartFolderName != "") { assemblyPartFolderName = string.Join("", assemblyPartFolderName.Split(Path.GetInvalidFileNameChars())); fullPathName += "\\" + assemblyPartFolderName; Directory.CreateDirectory(fullPathName); } fullPathName += "\\" + fileName + ".par"; Log.Debug("fullPathName: " + fullPathName); if (!File.Exists(fullPathName)) { partDocument.SaveCopyAs(fullPathName); } this.Document.Application.DoIdle(); partDocument.Close(false); this.Document.Application.DoIdle(); Marshal.FinalReleaseComObject(partDocument); this.HideConfigurationContainer(); int count = ((SolidEdgeAssembly.AssemblyDocument) this.Document).Occurrences.Count; if (count > 0) { SolidEdgeAssembly.Occurrence occurrence = ((SolidEdgeAssembly.AssemblyDocument) this.Document).Occurrences.Item(count); occurrence.GetTransform(out double OriginX, out double OriginY, out double OriginZ, out double AngleX, out double AngleY, out double AngleZ); Marshal.ReleaseComObject(occurrence); double offset = 0.05; occurrence = ((SolidEdgeAssembly.AssemblyDocument) this.Document).Occurrences.AddWithTransform(fullPathName, OriginX + offset, OriginY + offset, OriginZ + offset, AngleX, AngleY, AngleZ); // delete grounded relationship from occurrence.Relations3d SolidEdgeAssembly.Relations3d relation3d = (SolidEdgeAssembly.Relations3d)occurrence.Relations3d; foreach (var relation in relation3d) { Type type = relation.GetType(); // Get the value of the Type proprety via Reflection SolidEdgeFramework.ObjectType objectType = (SolidEdgeFramework.ObjectType)type.InvokeMember("Type", BindingFlags.GetProperty, null, relation, null); // Determine the relation type switch (objectType) { case SolidEdgeFramework.ObjectType.igGroundRelation3d: SolidEdgeAssembly.GroundRelation3d groundRelation3d = (SolidEdgeAssembly.GroundRelation3d)relation; groundRelation3d.Delete(); break; } } Marshal.FinalReleaseComObject(relation3d); Marshal.FinalReleaseComObject(occurrence); } else { ((SolidEdgeAssembly.AssemblyDocument) this.Document).Occurrences.AddWithTransform(fullPathName, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); } } }