×
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

Error Message - Type Mismatch

Error Message - Type Mismatch

Error Message - Type Mismatch

(OP)
I am running Visual Basic Code that loads into an assembly 2 parts, rotates into positon then does a cavity over 30 iterations.

I am getting a new error - type mismatch on the line


Set myFace = myFaces(0)

this is a line within a For loop that loops through the 30 iterations, and the error happens not the first time through the loop but about the 8th time through the loop.

I am trying to select the body before rotating it.  I use this technique because I dont always know what the last feature is in the tree, so I use this technique to automatically find it for me.


Why would it fail only after multiple iterations?  The Dim statement that I have is as follows:

Dim myFaces As Variant   

I have used the coding from the Solidworks 2007 API help file, even though I am running SW2009.  SW2009 Help file for API sucks.

Any thoughts how to avoid the error?

RE: Error Message - Type Mismatch

Is it possible that myFaces may be empty?  I'm guessing you're using GetLastFeatureAdded and then GetFaces, as per your previous threads?  If the last feature added doesn't create/affect geometry, it won't have any faces, and GetFaces will return something unusable.  I think you could test myFaces to make sure it's not empty with IsArray.

-handleman, CSWP (The new, easy test)

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