Results 1 to 10 of 10

Thread: what does mwan, user-type not defined?

  1. #1

    Thread Starter
    Addicted Member thiru_rajamani's Avatar
    Join Date
    Aug 2004
    Location
    Chennai,India
    Posts
    214

    Question what does mwan, user-type not defined?

    Dear all,
    when i am trying to one vb module written for solidworks it shows one error message as follows

    "user-type not defined"

    what does mean, user-type not defined? and how to solve this?

    Thankyou
    Regards
    Rajamani

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951
    It appears that the code is referencing a data item that is defined as a non-standard data type (user data type). Check your data definitions.

  3. #3
    Addicted Member imbue's Avatar
    Join Date
    Aug 2002
    Location
    Midwest USA
    Posts
    155
    It may be helpful if you post the code, or at least the line you get the error on.

    Basically somewhere in your program you are using a custom type and not telling VB what it is or how to use it. If you are using a module someone else wrote you are probably missing part of it.

  4. #4

    Thread Starter
    Addicted Member thiru_rajamani's Avatar
    Join Date
    Aug 2004
    Location
    Chennai,India
    Posts
    214
    here the coding ii

    Option Explicit

    Public Enum swBodyType_e
    swSolidBody = 0
    swSheetBody = 1
    swWireBody = 2
    swMinimumBody = 3
    swGeneralBody = 4
    swEmptyBody = 5
    End Enum

    Public Enum swUserPreferenceStringValue_e
    swDefaultTemplatePart = 8
    End Enum

    Public Enum swCreateFeatureBodyOpts_e
    swCreateFeatureBodyCheck = &H1
    swCreateFeatureBodySimplify = &H2
    End Enum

    Public Enum swDwgPaperSizes_e
    swDwgPaperAsize = 0
    swDwgPaperAsizeVertical = 1
    swDwgPaperBsize = 2
    swDwgPaperCsize = 3
    swDwgPaperDsize = 4
    swDwgPaperEsize = 5
    swDwgPaperA4size = 6
    swDwgPaperA4sizeVertical = 7
    swDwgPaperA3size = 8
    swDwgPaperA2size = 9
    swDwgPaperA1size = 10
    swDwgPaperA0size = 11
    swDwgPapersUserDefined = 12
    End Enum

    Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swPart As SldWorks.PartDoc
    Dim swBody As SldWorks.Body2
    Dim swFace As SldWorks.face2
    Dim swLoop As SldWorks.Loop2
    Dim vEdgeArr As Variant
    Dim swCurve() As SldWorks.Curve
    Dim vCurveArr As Variant
    Dim swEdge As SldWorks.Edge
    Dim swTempBody As SldWorks.Body2
    Dim swSurf As SldWorks.surface
    Dim swSurfCopy As SldWorks.surface
    Dim sPartTemplateName As String
    Dim swNewModel As SldWorks.ModelDoc2
    Dim swNewPart As SldWorks.PartDoc
    Dim swFeat() As SldWorks.feature
    Dim swKnitFeat As SldWorks.feature
    Dim swThickFeat As SldWorks.feature
    Dim swNewFeatMgr As SldWorks.FeatureManager
    Dim i As Long
    Dim bRet As Boolean

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swPart = swModel
    Set swBody = swPart.Body

    ' create new part
    sPartTemplateName = swApp.GetUserPreferenceStringValue(swDefaultTemplatePart)
    Set swNewModel = swApp.NewDocument(sPartTemplateName, swDwgPaperAsize, 0#, 0#)
    Set swNewFeatMgr = swNewModel.FeatureManager
    Set swNewPart = swNewModel

    ReDim swFeat(0)

    Set swFace = swBody.GetFirstFace
    Do While Not swFace Is Nothing
    Set swLoop = swFace.GetFirstLoop
    Do While Not swLoop Is Nothing
    If swLoop.IsOuter Then
    vEdgeArr = swLoop.GetEdges
    If UBound(vEdgeArr) >= 0 Then
    ReDim swCurve(UBound(vEdgeArr))
    For i = 0 To UBound(vEdgeArr)
    Set swEdge = vEdgeArr(i)
    Set swCurve(i) = swEdge.GetCurve
    Next i
    vCurveArr = swCurve

    Set swSurf = swFace.GetSurface
    Set swSurfCopy = swSurf.Copy
    Set swTempBody = swSurfCopy.CreateTrimmedSheet(vCurveArr)

    ' typically returns NULL if the loop is
    ' perpendicular to the surface as in the
    ' end loops of a cylinder
    If Not swTempBody Is Nothing Then
    ' sheet body will only have one face
    Debug.Assert 1 = swTempBody.GetFaceCount
    Debug.Assert swSheetBody = swTempBody.GetType

    Set swFeat(UBound(swFeat)) = swNewPart.CreateFeatureFromBody3(swTempBody, False, swCreateFeatureBodyCheck)
    Debug.Assert Not swFeat(UBound(swFeat)) Is Nothing

    ReDim Preserve swFeat(UBound(swFeat) + 1)
    End If
    End If
    End If

    Set swLoop = swLoop.GetNext
    Loop

    Set swFace = swFace.GetNextFace
    Loop

    ' remove last, NULL feature
    ReDim Preserve swFeat(UBound(swFeat) - 1)

    swNewModel.ClearSelection2 True
    For i = 0 To UBound(swFeat)
    bRet = swFeat(i).Select2(True, 1): Debug.Assert bRet
    Next i

    swNewModel.InsertSewRefSurface

    ' make sure we've successfully sewn surfaces together
    Set swKnitFeat = swNewModel.FeatureByPositionReverse(0)
    Debug.Assert Not swKnitFeat Is Nothing
    Debug.Assert "SewRefSurface" = swKnitFeat.GetTypeName

    bRet = swKnitFeat.Select2(False, 1): Debug.Assert bRet

    Set swThickFeat = swNewFeatMgr.FeatureBossThicken(0.01, 0, 0, True, True, True, True)
    Debug.Assert Not swThickFeat Is Nothing
    End Sub
    Thanks
    Raj

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    On what line does the error occur? That will be the necessary clue.

  6. #6
    Addicted Member imbue's Avatar
    Join Date
    Aug 2002
    Location
    Midwest USA
    Posts
    155
    Vb is probably thinking that you are missing a UDT when you are really missing a reference. Have you setup any references for your project?

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    Judging from the code, that seems very likely, but the actual line that the error occurs on should pinpoint which reference was missing.

  8. #8

    Thread Starter
    Addicted Member thiru_rajamani's Avatar
    Join Date
    Aug 2004
    Location
    Chennai,India
    Posts
    214

    Question mistake line

    Hereby I attaching the screen shot of error message for your review and I did not set any references.
    If I have to set refernces means, pl. tell me how to do it?
    Thanks
    Raj

  9. #9
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    What is SldWorks? That is your problem. That looks like it might be a third party component, but I don't recognize it. You will need to go to Project|References, and select the proper reference for that, but since I don't know what it is, I don't know what the proper reference is.

  10. #10

    Thread Starter
    Addicted Member thiru_rajamani's Avatar
    Join Date
    Aug 2004
    Location
    Chennai,India
    Posts
    214

    Now I got it

    Thank you Shaggy Hiker and all,
    Now it is working, but some runtime errors are there. If I face trouble, I will get back to you.

    Once again Thankyou to all
    Thanks
    Raj

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width