Anonymous
in reply to:
Anonymous
05-08-2020
07:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
05-08-2020
07:35 AM
I found a solution to my problem. My code works now, but it doesn't apply a hatch. Instead, it applies a Solid fill. Inventor 2019 API does not support to application of a hatch pattern to a profile, only a solid fill. Apparently this feature is coming to Inventor 2021.
See the attached images.
Working Code:
'Definitions Dim oDoc As DrawingDocument Dim oSht As Sheet Dim oDV As DrawingView Dim oSketch As DrawingSketch Dim oDC As DrawingCurve 'Set a reference to the active document. This assumes it is a drawing document. oDoc = ThisApplication.ActiveDocument 'Set a reference to the active sheet. oSht = oDoc.ActiveSheet 'Loop through all views that currently exist on the active sheet For Each oDV In oSht.DrawingViews 'Create a new sketch on the active view oSketch = oDV.Sketches.Add 'Put the sketch in edit mode oSketch.Edit 'Set a reference to the transient geometry object Dim oTG As TransientGeometry oTG = ThisApplication.TransientGeometry 'Project all edges of the part shown in the view For Each oDC In oDV.DrawingCurves oSketch.AddByProjectingEntity(oDC) Next 'Create a profile from the projected edges Dim oProfile1 As Profile oProfile1 = oSketch.Profiles.AddForSolid(False, oCollection1) 'Fill the profile with a SOLID pattern Call oSketch.SketchFillRegions.Add(oProfile1) ''Fill the profile with a HATCH pattern (available only in Inventor 2021) 'Call oSketch.SketchHatchRegions.Add(oProfile1) 'Exit the sketch oSketch.ExitEdit Next