static void AddLineAndDimension(SolidEdgeDraft.DraftDocument draftDocument) { SolidEdgeDraft.Sheet sheet = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgeFrameworkSupport.Dimensions dimensions = null; SolidEdgeFrameworkSupport.Dimension dimension = null; SolidEdgeFrameworkSupport.DimStyle dimStyle = null; // Get a reference to the active sheet. sheet = draftDocument.ActiveSheet; // Get a reference to the Lines2d collection. lines2d = sheet.Lines2d; // Draw a new line. line2d = lines2d.AddBy2Points( x1: 0.2, y1: 0.2, x2: 0.3, y2: 0.2); // Get a reference to the Dimensions collection. dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions; // Add a dimension to the line. dimension = dimensions.AddLength(line2d); // Get a reference to the dimension style. // DimStyle has a ton of options... dimStyle = dimension.Style; }
static void ReportItem(SolidEdgeFrameworkSupport.Dimension dimension) { Console.WriteLine("DisplayName: {0}", dimension.DisplayName); Console.WriteLine("ExposeName: {0}", dimension.ExposeName); Console.WriteLine("Name: {0}", dimension.Name); Console.WriteLine("SystemName: {0}", dimension.SystemName); Console.WriteLine("VariableTableName: {0}", dimension.VariableTableName); }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeDraft.DraftDocument draftDocument = null; SolidEdgeDraft.Sheet sheet = null; SolidEdgeFrameworkSupport.Lines2d lines2d = null; SolidEdgeFrameworkSupport.Line2d line2d = null; SolidEdgeFrameworkSupport.Dimensions dimensions = null; SolidEdgeFrameworkSupport.Dimension dimension = null; SolidEdgeFrameworkSupport.DimStyle dimStyle = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true); // Get a reference to the documents collection. documents = application.Documents; // Create a new draft document. draftDocument = documents.AddDraftDocument(); // Get a reference to the active sheet. sheet = draftDocument.ActiveSheet; // Get a reference to the Lines2d collection. lines2d = sheet.Lines2d; // Draw a new line. line2d = lines2d.AddBy2Points( x1: 0.2, y1: 0.2, x2: 0.3, y2: 0.2); // Get a reference to the Dimensions collection. dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions; // Add a dimension to the line. dimension = dimensions.AddLength(line2d); // Get a reference to the dimension style. // DimStyle has a ton of options... dimStyle = dimension.Style; } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void AddPartViewAndDimension(SolidEdgeDraft.DraftDocument draftDocument) { SolidEdgeDraft.Sheet sheet = null; SolidEdgeDraft.ModelLinks modelLinks = null; SolidEdgeDraft.ModelLink modelLink = null; SolidEdgeDraft.DrawingViews drawingViews = null; SolidEdgeDraft.DrawingView drawingView = null; DirectoryInfo trainingDirectory = GetTrainingDirectory(); string fileName = Path.Combine(trainingDirectory.FullName, "2holebar.par"); SolidEdgeDraft.DVLines2d dvLines2d = null; SolidEdgeDraft.DVLine2d dvLine2d = null; SolidEdgeFrameworkSupport.Dimensions dimensions = null; SolidEdgeFrameworkSupport.Dimension dimension = null; SolidEdgeFrameworkSupport.DimStyle dimStyle = null; // Get a reference to the active sheet. sheet = draftDocument.ActiveSheet; // Get a reference to the ModelLinks collection. modelLinks = draftDocument.ModelLinks; // Add a new model link. modelLink = modelLinks.Add(fileName); // Get a reference to the DrawingViews collection. drawingViews = sheet.DrawingViews; // Add a new part drawing view. drawingView = drawingViews.AddPartView( From: modelLink, Orientation: SolidEdgeDraft.ViewOrientationConstants.igDimetricTopBackLeftView, Scale: 5.0, x: 0.4, y: 0.4, ViewType: SolidEdgeDraft.PartDrawingViewTypeConstants.sePartDesignedView); // Get a reference to the DVLines2d collection. dvLines2d = drawingView.DVLines2d; // Get the 1st drawing view 2D line. dvLine2d = dvLines2d.Item(1); // Get a reference to the Dimensions collection. dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions; // Add a dimension to the line. dimension = dimensions.AddLength(dvLine2d.Reference); // Few changes to make the dimensions look right. dimension.ProjectionLineDirection = true; dimension.TrackDistance = 0.02; // Get a reference to the dimension style. // DimStyle has a ton of options... dimStyle = dimension.Style; }
public static void ReportVariables(SolidEdgeFramework.SolidEdgeDocument document) { SolidEdgeFramework.Variables variables = null; SolidEdgeFramework.VariableList variableList = null; SolidEdgeFramework.variable variable = null; SolidEdgeFrameworkSupport.Dimension dimension = null; if (document == null) { throw new ArgumentNullException("document"); } // Get a reference to the Variables collection. variables = (SolidEdgeFramework.Variables)document.Variables; // Get a reference to the variablelist. variableList = (SolidEdgeFramework.VariableList)variables.Query( pFindCriterium: "*", NamedBy: SolidEdgeConstants.VariableNameBy.seVariableNameByBoth, VarType: SolidEdgeConstants.VariableVarType.SeVariableVarTypeBoth); // Process variables. foreach (var variableListItem in variableList.OfType <object>()) { // Not used in this sample but a good example of how to get the runtime type. var variableListItemType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(variableListItem); // Use helper class to get the object type. var objectType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgeFramework.ObjectType>(variableListItem, "Type", (SolidEdgeFramework.ObjectType) 0); // Process the specific variable item type. switch (objectType) { case SolidEdgeFramework.ObjectType.igDimension: // Get a reference to the dimension. dimension = (SolidEdgeFrameworkSupport.Dimension)variableListItem; Console.WriteLine("Dimension: '{0}' = '{1}' ({2})", dimension.DisplayName, dimension.Value, objectType); break; case SolidEdgeFramework.ObjectType.igVariable: variable = (SolidEdgeFramework.variable)variableListItem; Console.WriteLine("Variable: '{0}' = '{1}' ({2})", variable.DisplayName, variable.Value, objectType); break; default: // Other SolidEdgeConstants.ObjectType's may exist. break; } } }
static void ProcessVariables(SolidEdgeFramework.Variables variables) { SolidEdgeFramework.VariableList variableList = null; SolidEdgeFramework.variable variable = null; SolidEdgeFrameworkSupport.Dimension dimension = null; dynamic variableListItem = null; // In C#, the dynamic keyword is used so we don't have to call InvokeMember(). // Get a reference to the variablelist. variableList = (SolidEdgeFramework.VariableList)variables.Query( pFindCriterium: "*", NamedBy: SolidEdgeConstants.VariableNameBy.seVariableNameByBoth, VarType: SolidEdgeConstants.VariableVarType.SeVariableVarTypeBoth); // Process variables. for (int i = 1; i <= variableList.Count; i++) { // Get a reference to variable item. variableListItem = variableList.Item(i); // Determine the variable item type. SolidEdgeConstants.ObjectType objectType = (SolidEdgeConstants.ObjectType)variableListItem.Type; Console.WriteLine("Variable({0}) is of type '{1}'", i, objectType); // Process the specific variable item type. switch (objectType) { case SolidEdgeConstants.ObjectType.igDimension: dimension = (SolidEdgeFrameworkSupport.Dimension)variableListItem; break; case SolidEdgeConstants.ObjectType.igVariable: variable = (SolidEdgeFramework.variable)variableListItem; break; default: // Other SolidEdgeConstants.ObjectType's may exist. break; } } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgePart.PartDocument document = null; SolidEdgeFramework.Variables variables = null; SolidEdgeFramework.VariableList variableList = null; SolidEdgeFramework.variable variable = null; SolidEdgeFrameworkSupport.Dimension dimension = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(); // Get a reference to the active document. document = application.GetActiveDocument <SolidEdgePart.PartDocument>(false); // Make sure we have a document. if (document != null) { VariablesHelper.ReportVariables(document); } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
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); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeAssembly.AssemblyDocument document = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(); // Get a reference to the active document. document = application.GetActiveDocument <SolidEdgeAssembly.AssemblyDocument>(false); // Make sure we have a document. if (document != null) { SolidEdgeFramework.Variables variables = null; SolidEdgeFramework.VariableList variableList = null; SolidEdgeFramework.variable variable = null; SolidEdgeFrameworkSupport.Dimension dimension = null; if (document == null) { throw new ArgumentNullException("document"); } // Get a reference to the Variables collection. variables = (SolidEdgeFramework.Variables)document.Variables; // Get a reference to the variablelist. variableList = (SolidEdgeFramework.VariableList)variables.Query( pFindCriterium: "*", NamedBy: SolidEdgeConstants.VariableNameBy.seVariableNameByBoth, VarType: SolidEdgeConstants.VariableVarType.SeVariableVarTypeBoth); // Process variables. foreach (var variableListItem in variableList.OfType <object>()) { // Not used in this sample but a good example of how to get the runtime type. var variableListItemType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(variableListItem); // Use helper class to get the object type. var objectType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgeFramework.ObjectType>(variableListItem, "Type", (SolidEdgeFramework.ObjectType) 0); // Process the specific variable item type. switch (objectType) { case SolidEdgeFramework.ObjectType.igDimension: // Get a reference to the dimension. dimension = (SolidEdgeFrameworkSupport.Dimension)variableListItem; Console.WriteLine("Dimension: '{0}' = '{1}' ({2})", dimension.DisplayName, dimension.Value, objectType); break; case SolidEdgeFramework.ObjectType.igVariable: variable = (SolidEdgeFramework.variable)variableListItem; Console.WriteLine("Variable: '{0}' = '{1}' ({2})", variable.DisplayName, variable.Value, objectType); break; default: // Other SolidEdgeConstants.ObjectType's may exist. break; } } } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgeFramework.Documents documents = null; SolidEdgeDraft.DraftDocument draftDocument = null; SolidEdgeDraft.ModelLinks modelLinks = null; SolidEdgeDraft.ModelLink modelLink = null; SolidEdgeDraft.Sheet sheet = null; SolidEdgeDraft.DrawingViews drawingViews = null; SolidEdgeDraft.DrawingView drawingView = null; SolidEdgeDraft.DVLines2d dvLines2d = null; SolidEdgeDraft.DVLine2d dvLine2d = null; SolidEdgeFrameworkSupport.Dimensions dimensions = null; SolidEdgeFrameworkSupport.Dimension dimension = null; SolidEdgeFrameworkSupport.DimStyle dimStyle = null; string filename = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true); // Get a reference to the documents collection. documents = application.Documents; // Create a new draft document. draftDocument = documents.AddDraftDocument(); // Get a reference to the ModelLinks collection. modelLinks = draftDocument.ModelLinks; // Build path to part file. filename = System.IO.Path.Combine(SolidEdgeCommunity.SolidEdgeUtils.GetTrainingFolderPath(), "2holebar.par"); // Add a new model link. modelLink = modelLinks.Add(filename); // Get a reference to the active sheet. sheet = draftDocument.ActiveSheet; // Get a reference to the DrawingViews collection. drawingViews = sheet.DrawingViews; // Add a new part drawing view. drawingView = drawingViews.AddPartView( From: modelLink, Orientation: SolidEdgeDraft.ViewOrientationConstants.igDimetricTopBackLeftView, Scale: 5.0, x: 0.4, y: 0.4, ViewType: SolidEdgeDraft.PartDrawingViewTypeConstants.sePartDesignedView); // Get a reference to the DVLines2d collection. dvLines2d = drawingView.DVLines2d; // Get the 1st drawing view 2D line. dvLine2d = dvLines2d.Item(1); // Get a reference to the Dimensions collection. dimensions = (SolidEdgeFrameworkSupport.Dimensions)sheet.Dimensions; // Add a dimension to the line. dimension = dimensions.AddLength(dvLine2d.Reference); // Few changes to make the dimensions look right. dimension.ProjectionLineDirection = true; dimension.TrackDistance = 0.02; // Get a reference to the dimension style. // DimStyle has a ton of options... dimStyle = dimension.Style; } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
static void Main(string[] args) { SolidEdgeFramework.Application application = null; SolidEdgePart.SheetMetalDocument sheetMetalDocument = null; SolidEdgePart.FamilyMembers familyMembers = null; SolidEdgePart.Round round = null; SolidEdgePart.UserDefinedPattern userDefinedPattern = null; SolidEdgeFrameworkSupport.Dimension dimension = null; try { // Register with OLE to handle concurrency issues on the current thread. SolidEdgeCommunity.OleMessageFilter.Register(); // Connect to or start Solid Edge. application = SolidEdgeCommunity.SolidEdgeUtils.Connect(true, true); // Bring Solid Edge to the foreground. application.Activate(); // Get a reference to the active part document. sheetMetalDocument = application.GetActiveDocument <SolidEdgePart.SheetMetalDocument>(false); if (sheetMetalDocument != null) { // Get a reference to the FamilyMembers collection. familyMembers = sheetMetalDocument.FamilyMembers; // Interate through the family members. foreach (var familyMember in familyMembers.OfType <SolidEdgePart.FamilyMember>()) { Console.WriteLine(familyMember.Name); // Determine FamilyMember MovePrecedence. switch (familyMember.MovePrecedence) { case SolidEdgePart.MovePrecedenceConstants.igModelMovePredecence: break; case SolidEdgePart.MovePrecedenceConstants.igSelectSetMovePrecedence: break; } // Warning: Accessing certain LiveRule[...] properties may throw an exception. //Console.WriteLine("igConcentricLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igConcentricLiveRule]); //Console.WriteLine("igCoplanarAxesAboutXLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igCoplanarAxesAboutXLiveRule]); //Console.WriteLine("igCoplanarAxesAboutYLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igCoplanarAxesAboutYLiveRule]); //Console.WriteLine("igCoplanarAxesAboutZLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igCoplanarAxesAboutZLiveRule]); //Console.WriteLine("igCoplanarAxesLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igCoplanarAxesLiveRule]); //Console.WriteLine("igCoplanarLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igCoplanarLiveRule]); //Console.WriteLine("igMaintainRadiusLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igMaintainRadiusLiveRule]); //Console.WriteLine("igOrthoLockingLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igOrthoLockingLiveRule]); //Console.WriteLine("igParallelLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igParallelLiveRule]); //Console.WriteLine("igPerpendicularLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igPerpendicularLiveRule]); //Console.WriteLine("igSymmetricLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igSymmetricLiveRule]); //Console.WriteLine("igSymmetricXYLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igSymmetricXYLiveRule]); //Console.WriteLine("igSymmetricYZLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igSymmetricYZLiveRule]); //Console.WriteLine("igSymmetricZXLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igSymmetricZXLiveRule]); //Console.WriteLine("igTangentEdgeLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igTangentEdgeLiveRule]); //Console.WriteLine("igTangentTouchingLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igTangentTouchingLiveRule]); //Console.WriteLine("igThicknessChainLiveRule - {0}", familyMember.LiveRule[SolidEdgePart.LiveRulesConstants.igThicknessChainLiveRule]); // Interate through the suppressed features of the current family member. for (int j = 1; j <= familyMember.SuppressedFeatureCount; j++) { object suppressedFeature = familyMember.SuppressedFeature[j]; // Use helper class to get the feature type. var featureType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgePart.FeatureTypeConstants>(suppressedFeature, "Type", (SolidEdgePart.FeatureTypeConstants) 0); switch (featureType) { case SolidEdgePart.FeatureTypeConstants.igRoundFeatureObject: round = (SolidEdgePart.Round)suppressedFeature; break; case SolidEdgePart.FeatureTypeConstants.igUserDefinedPatternFeatureObject: userDefinedPattern = (SolidEdgePart.UserDefinedPattern)suppressedFeature; break; } } // Interate through the variables of the current family member. for (int j = 1; j <= familyMember.VariableCount; j++) { object variable = familyMember.Variable[j]; // Use helper class to get the object type. var objectType = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue <SolidEdgeFramework.ObjectType>(variable, "Type", (SolidEdgeFramework.ObjectType) 0); switch (objectType) { case SolidEdgeFramework.ObjectType.igDimension: dimension = (SolidEdgeFrameworkSupport.Dimension)variable; break; } } } } else { throw new System.Exception("No active document."); } } catch (System.Exception ex) { Console.WriteLine(ex.Message); } finally { SolidEdgeCommunity.OleMessageFilter.Unregister(); } }
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); } } }