Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sheet Metal - API for Flat Pattern View in Drawing 1

Status
Not open for further replies.

shawn76o

Nuclear
Nov 14, 2006
31
0
0
US
I'm looking for an API function that can look at the Bend Line notes on a sheet metal part in a drawing. If the part is Face-Down, the macro will flip the part to Face-Up. This would work in the same way as when you click "Flip View" in the Flat Pattern Options while in a Drawing View of a sheet metal part.

I haven't been able to find anything on this, can anyone help me out?

Thanks!

Shawn Oelschlager
Production Control Ass't
Transco Products Inc.

SolidWorks Office Premium 2006 - SP4.1
Pentium 4 (2.8 GHz) - 2GB RAM
 
Replies continue below

Recommended for you

I'm not going to be able to help you on the API, but I'm curious. Do all bends on your parts always go in the same direction (up or down)?
 
I guess it would be the Bend-line notes. When a Flat Pattern view is selected and you right-click on the drawing component and select "Properties", I select "Display sheet metal bend notes", and the Up or Down side is displayed along with the angle of the bend lines. You can manually click the button "Flip View" on the left hand of the screen under Flat Pattern Options. This is what I want a macro to do, based on the bend line notes showing UP or DOWN. We want the bend lines UP.

Shawn Oelschlager
Production Control Ass't
Transco Products Inc.

SolidWorks Office Premium 2006 - SP4.1
Pentium 4 (2.8 GHz) - 2GB RAM
 
CorBlimeyLimey,

Sorry about that, I did miss your point. That's a very good question. Like I said, I'm helping a co-worker (who happens to be out of the office today) so I'll have to ask him when he returns. I'm not sure if we'll have that situation, but I think we determine "Face Up" by the Bend Line notes. I'm not even sure whether the Bend Line notes are actually noting the direction of the bends, or if they're just a label chosen by the designer at an earlier stage. Can you tell me which is the case?

Shawn Oelschlager
Production Control Ass't
Transco Products Inc.

SolidWorks Office Premium 2006 - SP4.1
Pentium 4 (2.8 GHz) - 2GB RAM
 
There is an API call to determine the "Fixed Face" of the part model. Note that the call differs as to whether the part was created first from an extruded shape, then sheet metal was added or whether it was modeled initially as sheet metal (Base Flange).

There is also an API call for the drawing -

CreateFlatPatternViewFromModelView2

That will automatically create a flat pattern view on the drawing (in the correct orientation).

I'm not aware of any API functionality to read an existing view and flip the orientation...

CorBlimey - in our shop the press operators always want bend up instead of bend down so they can scribe the part on the bend up side (the side that the press contacts) with dimensions as indicated on the drawing - on parts that are bend up and bend down you usually put the side with more bends as "up".
 
engAlright,

I've seen the API call to determine the "Fixed Face" of a part, but I'm not sure how to use it. There's some argument that I need to pass to it or something, but I'm not sure what. The SW API Help doesn't show much, but here's what I have so far...

Code:
Sub main()

    Dim swApp                   As SldWorks.SldWorks
    Dim swModel                 As SldWorks.ModelDoc2
    Dim swSelMgr                As SldWorks.SelectionMgr
    Dim swSelData               As SldWorks.SelectData
    Dim swFeat                  As SldWorks.Feature
    Dim swSheetMetal            As SldWorks.SheetMetalFeatureData
    Dim swFixedFaceEnt          As SldWorks.Entity
    Dim bRet                    As Boolean
    Dim swFlatPattern           As SldWorks.FlatPatternFeatureData
    Dim strFlat                 As String
    Dim FeatureCount            As Long
    Dim FeatureName             As String
    Dim FeatureType             As String
    Dim i                       As Integer

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swSelData = swSelMgr.CreateSelectData
    Set swFeat = swSelMgr.GetSelectedObject5(1)
    'Set swSheetMetal = swFeat.GetDefinition
    FeatureCount = swModel.GetFeatureCount

    For i = 0 To FeatureCount
    FeatureName = swFeat.Name
    FeatureType = swFeat.GetTypeName
    If FeatureType = "FlatPattern" Then
        Set swFlatPattern = swFeat.GetDefinition
        strFlat = swFlatPattern.FixedFace
    End If
    Set swFeat = swFeat.GetNextFeature
    Next i
    ' Roll back the model to get access to fixed face

    bRet = swSheetMetal.AccessSelections(swModel, Nothing)
    Set swFixedFaceEnt = swSheetMetal.FixedReference
    If Not swFixedFaceEnt Is Nothing Then
        Debug.Print "Got fixed face or fixed edge"
        bRet = swFixedFaceEnt.Select4(False, swSelData): Debug.Assert bRet
    Else
        ' Do not have to specify fixed face or fixed edge in user interface,
        ' so NULL is a valid value
        Debug.Print "NULL fixed face or fixed edge"
    End If

    ' Cancel changes and roll back the model

    swSheetMetal.ReleaseSelectionAccess
    
End Sub

Where I have
Code:
strFlat = swFlatPattern.FixedFace

I'm trying to determine the Fixed Face but I'm getting "Error 91 - Object variable or With Variable not Set"
Can you tell me what I'm missing?

Shawn Oelschlager
Production Control Ass't
Transco Products Inc.

SolidWorks Office Premium 2006 - SP4.1
Pentium 4 (2.8 GHz) - 2GB RAM
 
I was looking to build a macro that would do exactly what you are trying to do shawn76o and have been emailing apisupport@solidworks.com. They told me that the command to flip the part (the button Flip View) does not exist yet they also said that since I emailed them they would raise the Priority level. So i recommend emailing them to have them raise the priority level even more.

I would love a command that would Flip View of a sheet metal part.
 
Status
Not open for further replies.
Back
Top