Showing results for 
Search instead for 
Did you mean: 

How to get Features from synchronous document ?

Valued Contributor
Valued Contributor

Hi All

i want to read features from Synchronous document and how should i suppress or unsupress perticular feature from it


Posted by: Yogesh Shinde
Post date: 3/14/2012 1:41:53 AM


Re: How to get Features from synchronous document ?

Valued Contributor
Valued Contributor



I'm doing this myself at the moment. I'm using Visual Basic. What are you using?




Posted by: Ian Burrows
Post date: 5/4/2012 6:02:53 AM

Re: How to get Features from synchronous document ?

Valued Contributor
Valued Contributor

Hi Yogesh


Here is a chunk of my code - You might find bit of it useful.


Also download SESpy.exe from JasonNewell


Imports SolidEdgeFramework

'Imports SolidEdgePart

Imports System.Runtime.InteropServices

Imports System

Imports System.Reflection

Imports System.Reflection.Emit

Imports System.Collections

Imports SolidEdgeConstants

Imports Microsoft.VisualBasic





Public Class Form1

Const NumNormalProps = 13


Const igFinite = 13


Public strChild(30) As String

Public strParent(30) As String

Public strPropVal(30) As String

Public strDate As String

Public strTitle As String

Public strSubject As String

Public strDrawn As String

Public strAppr As String

Public strDwgNo As String

Public strProject As String

Public strWeight As String

Public strMaterial As String

Public strPartID As String

Public strMatlID As String

Public strQTY As String

Public strUOM As String


Public objDocument As SolidEdgeFramework.SolidEdgeDocument = Nothing

Public objApplication As SolidEdgeFramework.Application = Nothing

Public objPart As SolidEdgePart.PartDocument = Nothing

Public objUOM As SolidEdgeFramework.UnitsOfMeasure = Nothing


Public objFeatureGroup As SolidEdgePart.FeatureGroup = Nothing 'Group

Public objFeatureGroups As SolidEdgePart.FeatureGroups = Nothing 'Group


Public objfeatures As SolidEdgePart.Features = Nothing 'Features

Public objfeature As SolidEdgeFrameworkSupport.FeatureControlFrame = Nothing

Public objAnyFeature As Object = Nothing

Public TotalFeatures, TotalHoles As Integer



Public objHoleDataCollection As SolidEdgePart.HoleDataCollection

Public objHoleData As SolidEdgePart.HoleData


Public objHoles As SolidEdgePart.Holes

Public objHoleProp As SolidEdgePart.Hole



Public CancelNow As Boolean


Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)


Public Class PartData

Inherits [Object]

Private DataName As String = ""

Friend Members As New ArrayList()


Public Sub New(ByVal PartDataName As String)

Me.DataName = PartDataName

End Sub


Public Property PartDataName() As String


Return Me.DataName

End Get

Set(ByVal Value As String)

Me.DataName = Value

End Set

End Property


Public ReadOnly Property MemberDetails() As ArrayList


Return Me.Members

End Get

End Property

End Class 'End PartData class


' Create a new ArrayList to hold the Customer objects.

Private PartDataArray As New ArrayList()






Dim OStatus As Long

Dim ODensity As Double

Dim OAccuracy As Double

Dim OVolume As Double

Dim OArea As Double

Dim OMass As Double

Dim COG() As Double

Dim COV(10) As Double

Dim EngCOV(10) As Double

Dim GMI(0 To 15) As Double

Dim PMI(0 To 10) As Double

Dim PA(0 To 9) As Double

Dim PA2(0 To 9) As Double

Dim PA3(0 To 9) As Double

Dim ROG(10) As Double

Dim RAA As Double

Dim OUpdateStatus As Boolean

Dim OIsSick As Boolean


Private m_application As SolidEdgeFramework.Application

'Dim objDimension As SolidEdgeFrameworkSupport.Dimension

'Dim DimCount As Integer


Private Sub Form1_Load(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles MyBase.Load


' Connect to a running instance of Solid Edge

m_application = Marshal.GetActiveObject("SolidEdge.Application")

Catch ex As System.Runtime.InteropServices.COMException

MsgBox("SolidEdge not running")


Catch ex As Exception

MessageBox.Show(ex.Message, "Error")


End Try

End Sub



'AttachedPropertyTables, AttributeQuery,

'Constructions, CoordinateSystems, DocumentEvents, FamilyMembers,

'HighlightSets, Properties, PropertyTableDefinitions, RoutingSlip, SelectSet,

'Sketches, SummaryInfo, UnitsOfMeasure,


Private Sub Button1_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles Extract.Click

'Dim objDocument As SolidEdgeFramework.SolidEdgeDocument = Nothing

'Dim objApplication As SolidEdgeFramework.Application = Nothing


'Dim objPart As SolidEdgePart.PartDocument = Nothing

Dim objVariables As SolidEdgeFramework.Variables = Nothing

Dim objVariable As SolidEdgeFramework.variable = Nothing

Dim objVariableList As SolidEdgeFramework.VariableList = Nothing


Dim objProfileSets As SolidEdgePart.ProfileSets = Nothing

Dim objProfileSet As SolidEdgePart.ProfileSet = Nothing

Dim objProfiles As SolidEdgePart.Profiles = Nothing

Dim objProfile As SolidEdgePart.Profile = Nothing


Dim objDimensions As SolidEdgeFrameworkSupport.Dimensions = Nothing

Dim objDimension As SolidEdgeFrameworkSupport.Dimension = Nothing


Dim objModels As SolidEdgePart.Models = Nothing

Dim objModel As SolidEdgePart.Model = Nothing


Dim VarCount, DimCount, ProfCount, TotalSets, TotalProfs, i, ii As Integer

Dim TotalModels, ModelCount, NextNode, DOCnode, Addhere As Integer



Dim sName As String

Dim sFormula As String

Dim sValue As String

'Dim dValue, X, Y As Double

'Dim dHexSize As Double




Dim objHole As Object = Nothing




'SolidEdgeFrameworkSupport.DimensionStyle.SmartDepthHoleThru As String

'SolidEdgePart.HoleData.HoleType As SolidEdgePart.FeaturePropertyConstants

'SolidEdgePart.Hole.Depth As Double


Dim objFModel As SolidEdgePart.Model = Nothing


Dim objSelectSet As SolidEdgeFramework.SelectSet = Nothing


Dim objConstructions As SolidEdgePart.Constructions = Nothing

Dim objCopyConstructions As SolidEdgePart.CopyConstructions = Nothing

Dim objBooleanFeatures As SolidEdgePart.BooleanFeatures = Nothing

'The number of solid to do the boolean opertation

Dim NumberOfTools As Integer = 1

'A array which contains these solids

Dim Tools() As Object = Nothing ' {objConstructions.Item(1).Body}

'A member of the BooleanFeatureConstants constant set that specifies the type of Boolean operation to perform.

Dim Operation As SolidEdgePart.BooleanFeatureConstants = Nothing 'SolidEdgePart.BooleanFeatureConstants.seBooleanSubtract


Dim objPropCollection As New Microsoft.VisualBasic.Collection()

Dim objProp As SolidEdgePart.PropertyDefinition = Nothing


Dim objFaces As SolidEdgeGeometry.Faces = Nothing


Dim objGeometry As Object = Nothing


Dim objPropertySets As SolidEdgeFramework.PropertySets = Nothing

Dim objProperties As SolidEdgeFramework.Properties = Nothing

Dim objProperty As SolidEdgeFramework.Property = Nothing











' Get a reference to the active document

objDocument = m_application.ActiveDocument

' Connect to a running instance of Solid Edge

objApplication = Marshal.GetActiveObject("SolidEdge.Application")

' Get a reference to the active document's unit of measure

objUOM = objDocument.UnitsOfMeasure

TextBox1.Text = "123.456"

TextBox3.Text = objDocument.FullName

' Get a reference to the active document

objPart = objApplication.ActiveDocument


' Using Type property, determine document type

Select Case objDocument.Type

Case SolidEdgeFramework.DocumentTypeConstants.igAssemblyDocument

TextBox4.Text = "Assembly Document"

Case SolidEdgeFramework.DocumentTypeConstants.igDraftDocument

TextBox4.Text = "Draft Document"

Case SolidEdgeFramework.DocumentTypeConstants.igPartDocument

TextBox4.Text = "Part Document"

Case SolidEdgeFramework.DocumentTypeConstants.igSheetMetalDocument

TextBox4.Text = "SheetMetal Document"

Case SolidEdgeFramework.DocumentTypeConstants.igUnknownDocument

TextBox4.Text = "Unknown Document"

Case SolidEdgeFramework.DocumentTypeConstants.igWeldmentAssemblyDocument

Console.WriteLine("Weldment Assembly Document")

Case SolidEdgeFramework.DocumentTypeConstants.igWeldmentDocument

Console.WriteLine("Weldment Document")

End Select


' Attempt to parse the UOM input by user

'dHexSize = objUOM.ParseUnit(UnitTypeConstants.igUnitDistance, TextBox1.Text)

TextBox2.Text = objUOM.FormatUnit(SolidEdgeFramework.UnitTypeConstants.igUnitDistance, TextBox1.Text)

' Update the 2nd textbox with the parsed UOM

'TextBox2.Text = dHexSize.ToString()


'Add a variable

' objVariable = objVariables.Add("NewVar", "1.5")

'Change the formula of the variable to a function

' objVariable.Formula = Math.Sin(0.1).ToString()

'Change the name of the variable

' objVariable.Name = "NewName"

'Change the value of the variable. This will not change

'the value of the variable

' objVariable.Value = 123





' Use the Query method to list all all user-defined

' variables and user-named Dimension objects and

' display in the debug window

' objVariableList = objVariables.Query("*")

' For Each objVariable In objVariableList




'Variables.Items.Add(objVariables.GetName(objVariable)) ' + " " + objVariables.GetFormula(objVariable))

' Next




' Make column headers.


' List the properties.

' Use the class you want to study instead of Form1.

Dim property_value As Object

Dim DOCproperties_info As PropertyInfo() = GetType(SolidEdgeFramework.SolidEdgeDocument).GetProperties()


' Suppress repainting the TreeView until all the objects have been created.

' TvwProperties.BeginUpdate()

' Clear the TreeView each time the method is called.


TvwProperties.Nodes.Add("DOC " + objDocument.Name)

DOCnode = TvwProperties.GetNodeCount(False) - 1


For xxx As Integer = 0 To DOCproperties_info.Length - 1

With DOCproperties_info(xxx)

If .GetIndexParameters().Length = 0 Then

property_value = .GetValue(objDocument, Nothing)

TvwProperties.Nodes(NextNode).Nodes.Add("DOC1", "(Value) " + property_value.ToString, 1)

TvwProperties.Nodes(NextNode).Nodes(xxx).Nodes.Add("DOC2", " (Name) " + .Name, 2)

If property_value Is Nothing Then

TvwProperties.Nodes(NextNode).Nodes(xxx).Nodes(0).Nodes.Add("DOC4", "(Type) " + .PropertyType.ToString, 3)


TvwProperties.Nodes(NextNode).Nodes(xxx).Nodes(0).Nodes.Add("DOC4", "(Type) " + .PropertyType.ToString, 3)

End If


TvwProperties.Nodes(NextNode).Nodes.Add("DOC1", "<array>", 1)

TvwProperties.Nodes(NextNode).Nodes(xxx).Nodes.Add("DOC2", .Name, 2)

TvwProperties.Nodes(NextNode).Nodes(xxx).Nodes(0).Nodes.Add("DOC3", .PropertyType.ToString, 3)

End If

End With

Next xxx


NextNode = TvwProperties.GetNodeCount(False) - 1

TvwProperties.Nodes.Add("DOX " + objDocument.Name)

DOCnode = TvwProperties.GetNodeCount(False) - 1

For ii = 1 To 1 'objDocument.Count

objPropertySets = objDocument.Properties

For iii = 1 To objDocument.Properties.count


'TvwProperties.Nodes(NextNode).Nodes.Add(objPropertySets.Item(iii).Name + " <<<<<< ")

'customerArray.Add(New Customer("Customer" + x.ToString()))

'PartDataArray.Add(New PartData("PartData" + objPropertySets.Item(iii).Name()))

TvwProperties.Nodes(DOCnode).Nodes.Add("DOX", objPropertySets.Item(iii).Name, 2)

'Addhere = PartData.Current

objProperties = objPropertySets.Item(iii)

For iiii = 1 To objProperties.Count

objProperty = objProperties.Item(iiii)


If objProperty.Value Is Nothing Then

sValue = objProperty.Name + " Nothing "


sValue = objProperty.Name + " " + objProperty.Value.ToString

End If

TvwProperties.Nodes(DOCnode).Nodes(iii - 1).Nodes.Add("DOX", sValue, 3)

'PartDataArray.Item(Addhere).MemberDetails.Add(New sValue)

Next iiii

Next iii

Next ii





' Get a reference to the variables collection

objVariables = objPart.Variables



TvwProperties.Nodes.Add(New TreeNode("PART"))

NextNode = TvwProperties.GetNodeCount(False) - 1

Dim PartProperties_info As PropertyInfo() = GetType(SolidEdgePart.PartDocument).GetProperties()


For xxx As Integer = 0 To PartProperties_info.Length - 1

With PartProperties_info(xxx)

If .GetIndexParameters().Length = 0 Then

property_value = .GetValue(objPart, Nothing)


If property_value Is Nothing Then

TvwProperties.Nodes(NextNode).Nodes.Add("PROP", .Name, 1)


TvwProperties.Nodes(NextNode).Nodes.Add("PROP", .Name, 1)

End If


TvwProperties.Nodes(NextNode).Nodes.Add("PROP", "<array>" _

+ " (N) " + .Name _

+ " (T) " + .PropertyType.ToString, 1)

End If


Select Case .Name

Case "Models"


' Get a reference to the models collection

objModels = objPart.Models

TotalModels = objModels.Count

ModelCount = 1

TvwProperties.Nodes(NextNode).Nodes(0).Nodes.Add("MOD", "Model Data ", 1)

Select Case SelectedFeature.Checked

Case True

'ASSUME - only 1 model

objModel = objModels.Item(1)

Features.Items.Add(String.Format("Assumed Model Item = {0}", 1) + _

" DisplayName=" + objModel.DisplayName + _

" Hole Count =" + objModel.Holes.Count.ToString)

TvwProperties.Nodes(NextNode).Nodes(0).Nodes.Add("MOD1", String.Format("Assumed Model Item = {0}", 1), 2)

Features.Items.Add(" Number of shells ( in Models(i).Body )= " + objModel.Body.Shells.Count.ToString)

TvwProperties.Nodes(NextNode).Nodes(0).Nodes.Add("MOD1", " Number of shells ( in Models(i).Body )= " _


Posted by: Ian Burrows
Post date: 5/7/2012 9:14:49 AM

Re: How to get Features from synchronous document ?

Valued Contributor
Valued Contributor

You can pick features by identifying the ones you want by their properties which you can read


Posted by: Ian Burrows
Post date: 5/7/2012 12:37:42 PM

Re: How to get Features from synchronous document ?

Valued Contributor
Valued Contributor

I just encountered this the other day. When you get a Sync feature from a PartDocument collection like Rounds or Holes, you actually are getting a FaceSet object, which doesn't support the suppress property.


To distinguish the modeling mode, use the ModelingModeType property. If Hole features are added to the part in Ordered mode, then iterating over the Holes collection should give Hole objects instead of FaceSets.


Posted by: Jay Carlton
Post date: 5/17/2012 5:12:22 PM