×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Flat Pattern import from view palette Macro Question.

Flat Pattern import from view palette Macro Question.

Flat Pattern import from view palette Macro Question.

(OP)
Hi,

I found this example macro in the API help and it does pretty much what I need it to do with the exception of importing the flat pattern view. When I try and type the name of the view in it doesn't work. Any ideas? Here is the code that I have now.

Option Explicit

 

Dim swApp As SldWorks.SldWorks

 

Sub main()

    Dim swModel            As SldWorks.ModelDoc2

    Dim swDrawing          As SldWorks.DrawingDoc

    Dim swFeature          As SldWorks.Feature

    Dim swSubFeature       As SldWorks.Feature

    Dim swSheet            As SldWorks.Sheet

    Dim swView             As SldWorks.View

    Dim bFound             As Boolean

    Dim vViewNames         As Variant

    Dim vViewName          As Variant

    Dim strViewName        As String

    Dim lNumViews          As Long

    Dim dSheetScale        As Double

    Dim vSheetProperties   As Variant

    Dim nPaperSize         As swDwgPaperSizes_e

    Dim dWidth             As Double

    Dim dHeight            As Double

    

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swDrawing = swModel

    

    ' Get current sheet.

    Set swSheet = swDrawing.GetCurrentSheet

    vSheetProperties = swSheet.GetProperties

    dSheetScale = vSheetProperties(2) / vSheetProperties(3)

    nPaperSize = swSheet.GetSize(dWidth, dHeight)

    

    Debug.Print "Sheet scale  = " & dSheetScale

    Debug.Print "Sheet width  = " & dWidth

    Debug.Print "Sheet height = " & dHeight

    

    lNumViews = 0

    vViewNames = swDrawing.GetDrawingPaletteViewNames

        

    If (Not (IsEmpty(vViewNames))) Then

        lNumViews = (UBound(vViewNames) - LBound(vViewNames) + 1)

        Debug.Print "Number of views on palette = " & lNumViews

        For Each vViewName In vViewNames

            strViewName = vViewName

            Debug.Print strViewName

            If (strViewName = "*Top") Then

                Set swView = swDrawing.DropDrawingViewFromPalette2(strViewName, 0.175, 0.235, 0#)

                Debug.Print "  Dropped => " & swView.Name

            End If

            If (strViewName = "*Isometric") Then

                Set swView = swDrawing.DropDrawingViewFromPalette2(strViewName, 0.16, 0.11, 0#)

                Debug.Print "  Dropped => " & swView.Name

            End If

            If (strViewName = "*Right") Then

                Set swView = swDrawing.DropDrawingViewFromPalette2(strViewName, 0.125, 0.235, 0#)

                Debug.Print "  Dropped => " & swView.Name

            End If

        Next vViewName

    End If
    

End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources