Reply

Edgebar - Check for Under-Constrained Warning

I am currently looping through each flat pattern edgebar feature. I am able to find most errors/warnings with no problem.

 

 I am having issues identifying the "The sketch/profile is under-constrainted and will be less predictable during edits." warning.  

 

Calling the Status method on the edgebar feature returns FeatureStatusConstants.igFeatureOK

 

 

Any help would be SUPER!

9 REPLIES

Re: Edgebar - Check for Under-Constrained Warning

Have you checked the object with Solid Edge Spy for any suspicious properties? Normally that helps a lot to find what you are looking for.

Re: Edgebar - Check for Under-Constrained Warning

I have looked, no luck Smiley Sad

Re: Edgebar - Check for Under-Constrained Warning

Anyone, please? D:

Re: Edgebar - Check for Under-Constrained Warning

The Status property has an optional argument for the status message. Did you try to use this parameter to see, if the message is returned for that feature?

You might than look for an existing message, if the status is OK. By default, the message is empty for valid features.

Dim objDoc As SolidEdgePart.SheetMetalDocument = objApp.ActiveDocument
Dim status As SolidEdgePart.FeatureStatusConstants
Dim strDesc As String = ""
For Each objFeat In objDoc.FlatPatternEdgebarFeatures
  status = objFeat.Status(strDesc)
  Diagnostics.Debug.Print("Feature: " & objFeat.DisplayName & ",  status: " & status & ",  desc: [" & strDesc & "]")
Next

 

Re: Edgebar - Check for Under-Constrained Warning

Hi there.

 

I was running into the same problem, try to guess from the API all properties with underconstrained sketches on it, but the method explained is not working for me.

 

The argument passed to get the "Status" property is Nothing with under-constrained features. More or less this is my code, which works fine except for the under-constrained stuff:

 

Dim part As SolidEdgePart.PartDocument = CType(document, SolidEdgePart.PartDocument)

                    If part.DesignEdgebarFeatures IsNot Nothing AndAlso part.DesignEdgebarFeatures.Count > 1 Then
                        For j As Integer = 1 To part.DesignEdgebarFeatures.Count

                            'Each feature is a different type of object, but all of them share certain properties, which are the interesintg to read:                   
                            Dim featureType As SolidEdgePart.FeatureTypeConstants
                            Dim featureStatus As SolidEdgePart.FeatureStatusConstants
                            Dim featureStatusInfo As String = Nothing
                            Dim featureName As String
                            Dim featureSuppress As Boolean

                            Dim feature As Object = part.DesignEdgebarFeatures.Item(j)

                            featureType = CType(feature.GetType().InvokeMember(RBC_FETURE_TYPE_PROP, Reflection.BindingFlags.GetProperty, Nothing, feature, Nothing), SolidEdgePart.FeatureTypeConstants)
                            featureStatus = CType(feature.GetType().InvokeMember(RBC_FETURE_STATUS_PROP, Reflection.BindingFlags.GetProperty, Nothing, feature, {featureStatusInfo}), SolidEdgePart.FeatureStatusConstants)
                            featureName = CType(feature.GetType().InvokeMember(RBC_FETURE_NAME_PROP, Reflection.BindingFlags.GetProperty, Nothing, feature, Nothing), String)

                            'Not all features have suppress state, so use exceptions management
                            Try
                                featureSuppress = CType(feature.GetType().InvokeMember(RBC_FETURE_SUPPRESS_PROP, Reflection.BindingFlags.GetProperty, Nothing, feature, Nothing), Boolean)
                            Catch
                                'For ityems without suppressing possibilities, we asume they are not suppressed!
                                featureSuppress = False
                            End Try
                          
                        Next
                    End If

 

I'm using InvokeMember in order to read the same properties no matter the exact type of feature, if available. I have also tried a "more direct" approach, but the result is always the same: no information is dumped into the status extra argument, so it's not a fault of InvokeMember

 

It's really not possible to know from the appy if a feature has underconstrained info? In my company I need to supervise good modeling habits for newcomers, and adding this to my "Solid Edge Full Management Freak Application to Avoid Suicide" would be great, as I have done with broken links, failed features and a long long stuff.

Any ideas? Much thanks in advance!

Re: Edgebar - Check for Under-Constrained Warning

Javi,

 

I have just recognized that the Sketch object has a "IsUnderDefined" property. You may try to use that...

Re: Edgebar - Check for Under-Constrained Warning

Wow, that worked much thanks

 

However, applying that information to my app I have found further problems :-(

 

That property is available in standalone sketches but, for features with "embedded" sketches,I need to recall the profiles they are built from.

 

For features with just one sketch (like SolidEdgePart.ExtrudedProtusion), I can get the Profile property and then inspect its ProfileSet parent for looking for IsUnderDefined, which is there too.

 

The problem comes with features with more than one profile, such as SolidEdgePart.LoftedProtusion. In this case, I have the GetCrossSections method, defined in the documentation as:

  

Public Sub GetCrossSections( _
   ByRef NumCrossSections As Long, _
   ByRef CrossSections() As Object _
) 

 

I guess this method should be the way, along with GetTraceCurves, which provides aditional curves involved for other types of features.

 

The bad news is that I have no idea of what kind of object does this return, since I'm not able to make it work. GetCrossSections always launches an exception. It seems that I'm not correctly passing the parameters to the method. CrossSections() must be initialized (or at least it seems so), but I have no idea of how to do so, since I don't know nor the number of sections, not the type of object returned (Profile? ProfileSet?).

 

I have not find more useful info about this method, so any help will be welcomed. I think all this can be qute useful.

 

Thanks in advance,

 

 

 

 

Re: Edgebar - Check for Under-Constrained Warning

For those interested, I have been testing things and I have managed to make GetCrossSections work, or at least it seems so.

 

As I see, you need to pass an initialized array, although, since you don't know the number of sections, you'll have to give an initial "big enough" size and then delete all those elements you don't need. Something like this:

 

...
Dim features As SolidEdgePart.EdgebarFeatures = partDocument.DesignEdgebarFeatures

'Navigate along all features of the edgebar tree
For i As Integer = 1 To features.Count Dim feature As Object = features.Item(i) Dim sectionsCount As Integer Dim sections As System.Array = System.Array.CreateInstance(GetType(SolidEdgePart.Profile), 32) Dim args As Object() = {sectionsCount, sections}
'Let's see if we have a lofted protusion Try CType(feature, SolidEdgePart.LoftedProtrusion).GetCrossSections(sectionsCount, sections)

'Use sectionsCount to clean sections array
... Cath 'We don't have a lofted protusion! End Try Next

This works fine with the tested component, with sectionsCount = 2 and first two elements of sections containing the profiles (we can delete the rest). Maybe a bit ugly due to having to give an initial decent size; an exception is launched if all profiles can't be kept into the array.

 

The previous approach needs to try each feature type in order to call the method and test if it's possible trough exception catching. I tried a more generalist approach in this way:

 

...
Dim features As SolidEdgePart.EdgebarFeatures = partDocument.DesignEdgebarFeatures

'Navigate along all features of the edgebar tree
For i As Integer = 1 To features.Count
  Dim feature As Object = features.Item(i)

  Dim sectionsCount As Integer
  Dim sections As System.Array =      System.Array.CreateInstance(GetType(SolidEdgePart.Profile), 32)
  Dim args As Object() = {sectionsCount, sections}

  Try
    feature.GetType().InvokeMember("GetCrossSections", BindingFlags.InvokeMethod , Nothing, feature, args)
  Cath
    'We don't have a feature with more than one profile!
  End Try

Next

 

To my surprise, calling the method trough InvokeMember does not work. It doesn't fire any exception, but none of the arguments passed to GetCrossSections gets any info: they remain untouched.

 

As you can imagine, my goal here is study the whole tree, and having to test each type of feature, casting, and calling the method is a bit of pain, with dozens of features out there. I prefer to try "features with one profile" and then "features with more than one profile", to get the info prior to analyze it.

 

InvokeMember is working fine to study features with just one Profile. Somethnig like this:

 

Dim profile As SolidEdgePart.Profile = Nothing
Try
  profile = CType(feature.GetType().InvokeMember("Profile", Reflection.BindingFlags.GetProperty, Nothing, feature, Nothing), SolidEdgePart.Profile)
Catch
  'The feature is not any with just one profile
End Try

 

So, I guess the problems is using InvokeMember passing ByRef arguments to a function, which seems not to work as expected. Can anyone tell me what¡s wrong? I'm a vb.net newbie, so maybe I'm doing something wrong.

 

My apologies for the big extension, I hope this can be useful to people dealing with underdefined sketches, a quite undocumented stuff.

 

Thans for your interest.

Re: Edgebar - Check for Under-Constrained Warning

Javi,

you normally don't need to create a "big enough" array.

It should be enough to initialize an empty array!!

 

 Dim sections As System.Array = System.Array.CreateInstance(GetType(SolidEdgePart.​Profile), 0)

javigoca wrote:

...

As I see, you need to pass an initialized array, although, since you don't know the number of sections, you'll have to give an initial "big enough" size and then delete all those elements you don't need.

....