Macro to create axis for all Hole feature with specified diameter in component

Macro to create axis for all Hole feature with specified diameter in component

Anonymous
Not applicable
599 Views
3 Replies
Message 1 of 4

Macro to create axis for all Hole feature with specified diameter in component

Anonymous
Not applicable

Dear Experts,

 

I am looking for a macro , which executes the below steps after i run the macro:

 

1. Displays Form Box to enter Hole diameter value. 

2. Command manager to pick particular component.

3. Selects all Hole feature of specified Diameter (step 1) in the selected component (step 2)

4. Create Axis for all selected holes in that component.

5. Show count of newly created axis.

6. Show message if specified diameter hole does not exist in selected component.

7. End.

 

Kindly need help from our community's experts on this.

 

Thank you..

 

Regards,

Harish

 

 

0 Likes
Accepted solutions (1)
600 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Create Axis for all selected holes in that component.

 

       Do the user is going to select holes manually????

 

There are so many ways holes can be created.

    a. Rectangular Pattern,

    b. Circular Patterns,

    c. Holes based on No Of Points in one sketch (Can call it as User Pattern)

 

I am looking for a macro --> means what? a working macro

People can provide Idea or at least a portion of code for your problem in case if you are stuck at some point while coding.

 

Regards,

Mahadevaiah

Message 3 of 4

Anonymous
Not applicable

Hi Mahadevaiah,

 

Thank you for your response..

 

Regarding

Selection of Holes: All Hole feature to be identified by Code for the selected component in assembly and create axis , as soon as we run the macro. No manual selection of hole feature in components.

Hole Creation: We use hole wizard with combination of circular, rectangular pattern and most of the time we user pattern as mentioned in your post.

Macro: I am looking for a working macro. Keeping assembly ( All are sheet metal parts in assembly) open and active, we run the macro, where the code to execute the step mentioned in my first post.

 

Kindly need your suggestion..

 

Thank you again..

 

Regards,

Harish Kumar M

 

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

Hi Harish,

I made some code for my work. This is not gonna fulfill all your requirement. However you would get some idea if you are writing some macro's.

if i get time i will try fulfill all your requirements, but I doubt i would get time for that. 

Below is for Rectangular Pattern and Creating Axis only for the Parent Hole Feature (As my team doesn't want for occurrences) , and you can try the similar way with Circular Pattern Smiley Wink

 

------------------------------------------------------------------------

Private Sub AxisEnable_Chk()

Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument

Dim oParentHole As HoleFeature
Dim oWorkAxis As WorkAxis
Dim sStart As String

 

' Get all the Rectangular Pattern from Part Feature.
For i = 1 To oPartDoc.ComponentDefinition.Features.RectangularPatternFeatures.Count

Dim oRecPattern As RectangularPatternFeature
Set oRecPattern = oPartDoc.ComponentDefinition.Features.RectangularPatternFeatures.Item(i)

'To Avoid/Skip other Patterns whose Parent Pattern feature is not the Hole feature
sStart = Mid(oRecPattern.ParentFeatures.Item(1).Name, 1, 4)

If sStart = "Hole" Then
Set oParentHole = oRecPattern.ParentFeatures.Item(1)
Set oWorkAxis = oPartDoc.ComponentDefinition.WorkAxes.AddByRevolvedFace(oParentHole.Faces.Item(1), False)
MsgBox ThisApplication.ActiveDocument.DisplayName & ":" & vbCrLf & vbCrLf + "Axis Enabled for " & oRecPattern.Name & " - Parent Hole Feature"
End If

Next i

end sub

-------------------------------------------------

 

Hope this helps.

 

 

Regards

Alex