Feature status

Legend
Legend

Hello again,

i want to get the first feature with the status igFeatureRolledBack. On the great GitHub Samples from Jason Newell i found ReportEdgebarFeatures/Program.vb

 

edgebarFeatures = partDocument.DesignEdgebarFeatures

' Interate through the features.
For i As Integer = 1 To edgebarFeatures.Count
' Get the EdgebarFeature at current index.
Dim edgebarFeature As Object = edgebarFeatures.Item(i)

' Get the managed type.
Dim type = SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetType(edgebarFeature)
' How can i get the Feature Status here ???
Console.WriteLine("Item({0}) is of type '{1}'", i, type)

Next i

How can i get to the feature status?

Greetings from Germany
Christian Kunkel
https://c-k-m.info
3 REPLIES

Re: Feature status

Solution Partner Pioneer Solution Partner Pioneer
Solution Partner Pioneer

hello,

you can check this methode it works for me,

 

var FeatureType =SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue<SolidEdgePart.FeatureTypeConstants>(Feat.Item(i),"Type",(SolidEdgePart.FeatureTypeConstants)0);

var FeatureStatus =SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue<SolidEdgePart.FeatureStatusConstants>(Feat.Item(i),"Status",(SolidEdgePart.FeatureStatusConstants)0);

Console.WriteLine( "Feature Type = "+ FeatureType +" Feature Status ="+FeatureStatus );

 

Best Regards

Amani

Software Engineer

Tunisia

Re: Feature status

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Great answer!

 

In case it's not obvious to future readers, I just wanted to point out that the extension method SolidEdgeCommunity.Runtime.InteropServices.ComObject.GetPropertyValue() is available via the SolidEdge.Community NuGet package. The source for that package can be found in the SolidEdge.Community GitHub repository.

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Feature status

Legend
Legend

Here is my new class:

Imports System.Reflection
Imports SolidEdgeCommunity.Runtime.InteropServices
Imports SolidEdgePart

Public Class RollToFeatureHelper
	Private _part As PartDocument
	Private _offset As Integer

	Sub New(part As PartDocument)
		_part = part
		_offset = GetOffset()
	End Sub

	Public ReadOnly Property Offset As Integer
		Get
			Return _offset
		End Get
	End Property

	Public Property Part As PartDocument
		Get
			Return _part
		End Get
		Set(value As PartDocument)
			_part = value
			_offset = GetOffset()
		End Set
	End Property

	Public Sub RollBack()

		Dim edgebarFeatures As EdgebarFeatures
		Dim edgebarFeature As Object

		edgebarFeatures = _part.DesignEdgebarFeatures
		edgebarFeature = edgebarFeatures.Item(edgebarFeatures.Count - _offset)

		Try
			Dim type = ComObject.GetType(edgebarFeature)
			Dim meth As MethodInfo
			meth = type.GetMethod("RollToFeature")
			meth.Invoke(edgebarFeature, New Object() {})
		Catch ex As Exception

		End Try

	End Sub

	Private Function GetOffset() As Integer

		Dim edgebarFeatures As EdgebarFeatures
		Dim intOffSet As Integer

		'Get reference to EdgebarFeatures
		edgebarFeatures = _part.DesignEdgebarFeatures
		intOffSet = 0

		'Start at the end of the collection, should be the faster way most times
		For i As Integer = edgebarFeatures.Count To 1 Step -1
			Dim edgebarFeature As Object = edgebarFeatures.Item(i)
			Try
				'Dim type = ComObject.GetType(edgebarFeature)
				Dim featStatus = ComObject.GetPropertyValue(Of FeatureStatusConstants)(edgebarFeature, "Status")
				If Not featStatus = FeatureStatusConstants.igFeatureRolledBack Then Exit For
				intOffSet = intOffSet + 1
			Catch ex As Exception
				'If something goes wrong, roll to the last feature
				intOffSet = 0
			End Try
		Next
		Return intOffSet
	End Function

End Class

 

Greetings from Germany
Christian Kunkel
https://c-k-m.info