×
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

Hole Wizard Macro Problem

Hole Wizard Macro Problem

Hole Wizard 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?
 

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