Reply

Cut size X and Cut size Y after flat

Hi

When i flat some sheet metal manually i get two PMI dimensions of the cut size and some bounding rectangle.

When i flat using API, i get the flat pattern, but no PMI dimensions and no bounding rectangle.

Also, in the variables table the cut_size_x and cut_size_y variables are zero.

 

There is some option to get the bounding rectangle and the PMI dimensions automatically? exactly as i do by manual flat?

18 REPLIES

Re: Cut size X and Cut size Y after flat

I try show cut size, but get a error. Somebody have idea what i do wrong...

 

objFlatPatternModels = objPartDocument.FlatPatternModels
        objFlatPatternModel = objFlatPatternModels.FlatPatternModels.Item(1)
        objFlatPatternModel.Update()
        objFlatPatternModel.GetCutSize()

 

thanks

Re: Cut size X and Cut size Y after flat

I checked with a colleague in the know and he suggested calling the following method if you are creating the flat pattern through the API:

 

SolidEdge.Part.Interop.FlatPattern.SetCutSizeValues(MaxCutSizeX As Double, MaxCutSizeY As Double, ShowRangeBox As Boolean, AlarmOnX As Boolean, AlarmOnY As Boolean, UseDefaultValues As Boolean)

---
Aditya Gurushankar
Manager, Solid Edge Planning

Re: Cut size X and Cut size Y after flat

Dim objApp As SolidEdgeFramework.Application
    Dim objPartDocument As SolidEdgePart.SheetMetalDocument
    Dim objFlatPatternModels As SolidEdgePart.FlatPatternModels
    Dim objFlatPatternModel As SolidEdgePart.FlatPatternModel
    Dim objFlatPatterns As SolidEdgePart.FlatPatterns
    Dim objFlatPattern As SolidEdgePart.FlatPattern

Dim oMaxCutSizeX As Double
    Dim oMaxCutSizeY As Double
    Dim oShowRangeBox As Boolean
    Dim oAlarmOnX As Boolean
    Dim oAlarmOnY As Boolean
    Dim oUseDefaultValues As Boolean

 

objApp = Marshal.GetActiveObject("SolidEdge.Application")
        objPartDocument = objApp.ActiveDocument
        objFlatPatternModels = objPartDocument.FlatPatternModels
        objFlatPatternModel = objFlatPatternModels.Item(1)
        objFlatPatterns = objFlatPatternModel.FlatPatterns(1)
        objFlatPattern.SetCutSizeValues(MaxCutSizeX:=oMaxCutSizeX, MaxCutSizeY:=oMaxCutSizeY, ShowRangeBox:=oShowRangeBox, AlarmOnX:=oAlarmOnX, AlarmOnY:=oAlarmOnY, UseDefaultValues:=oUseDefaultValues)

 

Still is something wrong... any ideas ?

Re: Cut size X and Cut size Y after flat

I have resolved a problem myself. thanks !

Re: Cut size X and Cut size Y after flat

In your first post, you have not initialized any of the variables. I would expect at least oUseDefaultValues to be true, so the result is similar to whay you get through the UI.

 

Looks like all's well. It would help other readers if you could explain how you fixed the issue.


All the best,

Aditya

---
Aditya Gurushankar
Manager, Solid Edge Planning

Re: Cut size X and Cut size Y after flat

Hi all,

 

I thought that everything is ok, but somethimes my macro doesn`t work.

I get error "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"

in program line

"objFlatPatterns.Item(1).SetCutSizeValues(MaxCutSizeX:=oMaxCutSizeX, MaxCutSizeY:=oMaxCutSizeY, ShowRangeBox:=oShowRangeBox, AlarmOnX:=oAlarmOnX, AlarmOnY:=oAlarmOnY, UseDefaultValues:=oUseDefaultValues)"

 

 

Re: Cut size X and Cut size Y after flat

Hard to tell from you snippet since it is possible some of the variables you are passing in are in conflict. You may want to pass in only oUseDefaultValues=True.

If that doesn't work I suggest calling in an IR with your reseller or GTAC for help with the API.
---
Aditya Gurushankar
Manager, Solid Edge Planning

Re: Cut size X and Cut size Y after flat

 objApp = Marshal.GetActiveObject("SolidEdge.Application")
            objApp.Activate()
            objPartDocument = objApp.ActiveDocument
            objFlatPatternModels = objPartDocument.FlatPatternModels
            objFlatPatternModel = objFlatPatternModels.Item(1)
            objFlatPatterns = objFlatPatternModel.FlatPatterns
            objApp.DoIdle()
            GC.Collect()
            If objFlatPatterns.Count > 0 Then
                objFlatPattern = objFlatPatterns.Item(1)
                objFlatPattern.SetCutSizeValues(MaxCutSizeX:=oMaxCutSizeX, MaxCutSizeY:=oMaxCutSizeY, ShowRangeBox:=True, AlarmOnX:=oAlarmOnX, AlarmOnY:=oAlarmOnY, UseDefaultValues:=True)

 

I didn`t found any solution, any idea ?

Re: Cut size X and Cut size Y after flat

The following code worked for me:

 

Public Sub FlatPattern()

Dim objSMDocument As SolidEdge.Part.Interop.SheetMetalDocument

objSMDocument = objApp.ActiveDocument

 

Dim objFlatPatternModel As SolidEdge.Part.Interop.FlatPatternModel

objFlatPatternModel = objSMDocument.FlatPatternModels.Item(1)

 

Dim objFlatPatterns As SolidEdge.Part.Interop.FlatPatterns

objFlatPatterns = objFlatPatternModel.FlatPatterns

 

If objFlatPatterns.Count > 0 Then

Dim objFlatPattern As SolidEdge.Part.Interop.FlatPattern

objFlatPattern = objFlatPatterns.Item(1)

 

objFlatPattern.SetCutSizeValues(MaxCutSizeX:=0, MaxCutSizeY:=0, ShowRangeBox:=False, AlarmOnX:=False, AlarmOnY:=False, UseDefaultValues:=False)

End If

End Sub

 

AlarmOnX and AlarmOnY are for the length and width checkboxes. MaxCutSizeX and MaxCutSizeY are the values for the max values if AlarmOnX and AlarmOnY are respectively True. ShowRangeBox sets the "show cut size range and dimensions" checks box. And UseDefaultValues is the default values checkbox.

 

 

---
Aditya Gurushankar
Manager, Solid Edge Planning