Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: Anonymous

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