×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

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!

*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

holewizard macro problem

holewizard macro problem

holewizard macro problem

(OP)
We do most of our design via VBA /Excell/Soliworks programs.  We use common drawing files so that means a drawing file has to handle hole sizes that change.  Holes can change from various tap sizes to various drilled hole sizes in the same location.
 
I have been doing this by suppressing unused tapped holes and/or simple holes.  This is a pain because the dimensions do not automatically handle this - you either have to have a drawing with all the options dimensioned (and hidden, but that causes problems, too) or you have to manually dimension it every time.  Typically, we now have to erase all the unused ones since the hidden dangling dimensions make the drawing a real pain to work with.
 
In any case, this is the subroutine I am using:
 
Sub HoleWzChng(WzPart As ModelDoc2, WzHoleId As String, WzHoleSz As String, WzHoleTyp As Long)
 
Dim boolstatus As Boolean
Dim swFeatMgr As SldWorks.FeatureManager
Dim swFeatDataObj As Object
Dim swWzdHole As WizardHoleFeatureData2
Dim SelMgr As SelectionMgr
 
Set swFeatMgr = WzPart.FeatureManager
 
boolstatus = WzPart.Extension.SelectByID2(WzHoleId, "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)
If boolstatus = False Then Exit Sub
Set SelMgr = WzPart.SelectionManager
 
Set swFeatDataObj = SelMgr.GetSelectedObject6(1, -1)
WzPart.ClearSelection2 True
 
Set swWzdHole = swFeatDataObj.GetDefinition
 
boolstatus = swWzdHole.AccessSelections(WzPart, Nothing)
 
swWzdHole.Type = WzHoleTyp
If WzHoleTyp = swTapThru Then
    boolstatus = swWzdHole.ChangeStandard(swStandardAnsiInch, swStandardAnsiInchTappedHole, WzHoleSz)    'if tapped hole, WzHoleSz is a string like "1/2-13"
    swWzdHole.CosmeticThreadType = swCosmeticThreadWithCallout
Else
    boolstatus = swWzdHole.ChangeStandard(swStandardAnsiInch, swStandardAnsiInchFractionalDrillSizes, "1")  'if a drilled hole, WZHoleSz is the OD of the hole - still a string
    swWzdHole.ThruHoleDiameter = vaL(WzHoleSz) * 0.0254
End If
boolstatus = swFeatDataObj.ModifyDefinition(swWzdHole, WzPart, Nothing)
 
End Sub

It works, sort of.  All the information is put into the hole wizard and the drawing call out is correct, but the model doesn't look right unless you manually go into the hole feature, edit the feature (do nothing), and exit.  Restore defaults is not performed and the 2nd sketch (hole profile) has irrellevant junk in it (BIG countersunk hole).  Rebuild commands have no effect and neither does a macro trying to do the same thing.  
 
I have done some checking, and the changestandard command is putting in the right values, as near as I can tell, into the definition, but it is getting ignored.

Any body got any ideas?
 
 

RE: holewizard macro problem

(OP)
Finally figured this out.  

The code listed above doesn't work and any combinations tried resulted in interesting (and wrong) results.  Some of these results could not be fixed in code.  Unless I am missing something, the guys at SolidWorks have some serious bugs or, more likely, didn't bother to actually make the API commands work the way they were supposed to.

The only way I have found this can be done is to place a temporary point on the part.  Then you create and new hole using HoleWizard3 and use CopyWizardHole to update the hole you want to change.  Then you have to delete the hole you just created.  A VERY bizzarre way to have to do this.

You would think changing the type and/or size of a wizard hole would be something lots of people would want to do - its an almost required thing to do for automated design.

This issue has been somewhat typical for us.  Problems like this are beyond what our then provider could understand and no help from Solidworks was ever forthcoming.  We did not know why we were paying them the $1,000s for "support" so we stopped.  

RE: holewizard macro problem

(OP)
I know - but this is what pops up with Google.

RE: holewizard macro problem

Look for a SolidWorks forum in eng-tips.
Use the following:
site:eng-tips.com SolidWorks CAD VBA API

I got 413 hits, all in the 3D CAD forum. People that hang out on this forum only want to discuss FEA, CFD and Kinematics. Thanks.  

TOP
CSWP, BSSE
www.engtran.com  www.niswug.org
www.linkedin.com/in/engineeringtransport
Phenom IIx6 1100T = 8GB = FX1400 = XP64SP2 = SW2009SP3
"Node news is good news."

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! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close