- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to write a vba script to look at the flanges modeled within a sheet metal part and determine if they have a corner feature that is accessible. Essentially what I'm going for is whether the flange feature has more than 1 flange added and do they share a vertex, thus creating a corner feature. The flange feature creates a corner feature always, but unless there is a corner created within that flange, right-clicking on it to edit it results in an error message. I want VBA to essentially do that. However, it doesn't seem to matter how I try to access it following the object model map, I can't see anything useful. The sub here is as close as I think I've come, but it still just errors out on the 'for each ocornerfeature in oflangefeature' line and it doesn't seem to matter what i put after the 'oflangefeature'. Has anyone ever tried to do this? I'm not great at reading the object model map but I can gain access to flangedefinition-corneroptions and that doesn't seem to have anything useful in it either. Do I need to conduct a test? try to change a value and if I can't then it must not have a corner? I've been fighting this for a week now with no progress. Here's what I have so far, again this errors out.
Sub sheetmetalfeaturedisplay()
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
Dim osheetmetalcompdef As SheetMetalComponentDefinition
Set osheetmetalcompdef = oPartDoc.ComponentDefinition
Dim oFlangeFeature As flangeFeature
Dim oFeature As PartFeature
Dim oCornerFeature As cornerFeature
For Each oFeature In osheetmetalcompdef.Features
If TypeOf oFeature Is flangeFeature Then
Set oFlangeFeature = oFeature
Debug.Print "Flange Feature: " & oFlangeFeature.name
' Accessing CornerFeatures directly from FlangeFeature
For Each oCornerFeature In oFlangeFeature
Debug.Print "Corner Feature: " & oCornerFeature.name
' You can access other properties of oCornerFeature here
Next oCornerFeature
End If
Next
End Sub
Solved! Go to Solution.