Yes, you must create a profile of the region that you intend to fill. Here
is the modified code:
Public Sub DrawingSketchFill()
' Set a reference to the active document. This assumes it
' is a drawing document.
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
' Create a sketch on the active sheet
Dim oSketch As DrawingSketch
Set oSketch = oDoc.ActiveSheet.Sketches.Add
' Put the sketch in edit mode
oSketch.Edit
' Set a reference to the transient geometry object.
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
' Draw a circle in the sketch.
'Dim oCircle1 As SketchCircle
'Set oCircle1 =
oSketch.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(10, 30), 2)
Dim oRect1 As SketchEntitiesEnumerator
Set oRect1 =
oSketch.SketchLines.AddAsTwoPointRectangle(oTG.CreatePoint2d(1.27, 24.765),
oTG.CreatePoint2d(6.35, 26.67))
' Create a collection and add the entities of the rectangle.
Dim oCollection1 As ObjectCollection
Set oCollection1 =
ThisApplication.TransientObjects.CreateObjectCollection
Dim oSketchEntity As SketchEntity
For Each oSketchEntity In oRect1
oCollection1.Add oSketchEntity
Next
' Create a profile from the rectangle
Dim oProfile1 As Profile
Set oProfile1 = oSketch.Profiles.AddForSolid(False, oCollection1)
' Create a fill region based on the layer color.
Call oSketch.SketchFillRegions.Add(oProfile1)
End Sub
Sanjay-
wrote in message news:5642153@discussion.autodesk.com...
Below is part of AD's sample macro for SketchFillRegion with my
modifications for a Rectangle. I thought this would be simple since I don't
think I need to profile it. Or do I somehow need to profile each line and
add? I have tried oRect in place of oCollection for
oSketch.SketchFillRegions.Add(???)
Public Sub DrawingSketchFill()
' Set a reference to the active document. This assumes it
' is a drawing document.
Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument
' Create a sketch on the active sheet
Dim oSketch As DrawingSketch
Set oSketch = oDoc.ActiveSheet.Sketches.Add
' Put the sketch in edit mode
oSketch.Edit
' Set a reference to the transient geometry object.
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
' Draw a circle in the sketch.
'Dim oCircle1 As SketchCircle
'Set oCircle1 =
oSketch.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(10, 30), 2)
Dim oRect1 As SketchEntitiesEnumerator
Set oRect1 =
oSketch.SketchLines.AddAsTwoPointRectangle(oTG.CreatePoint2d(1.27, 24.765),
oTG.CreatePoint2d(6.35, 26.67))
' Create a collection and add the circle.
Dim oCollection1 As ObjectCollection
Set oCollection1 =
ThisApplication.TransientObjects.CreateObjectCollection
oCollection1.Add oRect1
' Create a profile from the first circle
'Dim oProfile1 As Profile
'Set oProfile1 = oSketch.Profiles.AddForSolid(False, oCollection1)
' Create a fill region based on the layer color.
Call oSketch.SketchFillRegions.Add(oCollection1)
Pete