Hide Table of Contents

Get B-Spline Surface Parameterization Data Example (VBA)

This example shows how to get B-spline parameterization data for a selected face or surface.

'----------------------------------------------------------------------------
' Preconditions:
' 1.  Open <SolidWorks_install_dir>\samples\tutorial\molds\telephone.sldprt.
' 2.  Select a face in the graphics area.
' 3.  Open an Immediate Window.
'
' Postconditions:
'   View the following parameterization data about the selected surface

'   in the Immediate Window:
'
'   * U minimum
'   * U maximum
'   * V minimum
'   * V maximum
'   * Boundary behaviors at U minimum, U maximum, V minimum, V maximum

'     as defined in swBoundType_e
'   * # of U and V properties
'   * U and V properties as defined in swParameterizationPropertyType_e
'   * U order
'   * V order
'   * # of control point columns
'   * # of control point rows
'   * Control point dimension:
'     3 - non-rational surfaces
'     4 - rational surfaces (weighted control points)
'   * U periodicity
'   * V periodicity
'   * Knot vector in the U direction
'     (# knots = (control point column count) + (U order))
'   * Knot vector in the V direction
'     (# knots = (control point row count) + (V order))
'   * Control point at row=2 and column=3 of the control point matrix
'----------------------------------------------------------------------------
Option Explicit
Sub main()

    Dim swApp                       As SldWorks.SldWorks
    Dim swModel                     As SldWorks.ModelDoc2
    Dim swSelMgr                    As SldWorks.SelectionMgr
    Dim swFace                      As SldWorks.Face2
    Dim swSurf                      As SldWorks.Surface
    Dim swSurfParam                 As SldWorks.SurfaceParameterizationData
    Dim swBSurfParam                As SldWorks.BSurfParamData
    Dim sense                       As Boolean
    Dim UKnots                      As Variant
    Dim VKnots                      As Variant
    Dim vCtrlPts                    As Variant
    Dim i                           As Integer
   

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swSelMgr = swModel.SelectionManager
    Set swFace = swSelMgr.GetSelectedObject5(1)
    Set swSurf = swFace.GetSurface
    Set swSurfParam = swSurf.Parameterization2
    Debug.Print "File = " & swModel.GetPathName
    Debug.Print "  Surface:"
    Debug.Print " U minimum is: " & swSurfParam.UMin
    Debug.Print " U minimum bound type is: " & swSurfParam.UMinBoundType
    Debug.Print " U maximum is: " & swSurfParam.UMax
    Debug.Print " U maximum bound type is: " & swSurfParam.UMaxBoundType
    Debug.Print " U property count is: " & swSurfParam.UPropertyNumber
    Dim varUProperties As Variant
    varUProperties = swSurfParam.UProperties
    Debug.Print " U properties: "
    For i = 0 To UBound(varUProperties)
        Debug.Print "    " & varUProperties(i)
    Next i
   

    Debug.Print " V minimum is: " & swSurfParam.VMin
    Debug.Print " V minimum bound type is: " & swSurfParam.VMinBoundType
    Debug.Print " V maximum is: " & swSurfParam.VMax
    Debug.Print " V maximum bound type is: " & swSurfParam.VMaxBoundType
    Debug.Print " V property count is: " & swSurfParam.VPropertyNumber
    Dim varVProperties As Variant
    varVProperties = swSurfParam.VProperties
    Debug.Print " V properties: "
    For i = 0 To UBound(varVProperties)
        Debug.Print "    " & varVProperties(i)
    Next i
   

    Set swBSurfParam = swSurf.GetBSurfParams3(False, False, swSurfParam, 0.01, sense)
   

    Debug.Print "U order is: " & swBSurfParam.UOrder
    Debug.Print "V order is: " & swBSurfParam.VOrder
    Debug.Print " Control point column count is: " & swBSurfParam.ControlPointColumnCount
    Debug.Print " Control point row count is: " & swBSurfParam.ControlPointRowCount
    Debug.Print " Control point dimension is: " & swBSurfParam.ControlPointDimension
    Debug.Print " U periodicity is: " & swBSurfParam.UPeriodicity
    Debug.Print " V periodicity is: " & swBSurfParam.VPeriodicity
   

    UKnots = swBSurfParam.UKnots
    Debug.Print "Knot vector in the U direction: "
    For i = 0 To UBound(UKnots)
        Debug.Print UKnots(i)
    Next i
    VKnots = swBSurfParam.VKnots
    Debug.Print "Knot vector in the V direction: "
    For i = 0 To UBound(VKnots)
        Debug.Print VKnots(i)
    Next i
   

    ' Get control points in row = 2, column = 3 of the control point matrix
    vCtrlPts = swBSurfParam.GetControlPoints(2, 3)
    Debug.Print "Control point at row=2 and column=3: "
    For i = 0 To UBound(vCtrlPts)
        Debug.Print vCtrlPts(i)
    Next i
End Sub



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Get B-Spline Surface Parameterization Data Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:



x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2013 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.