Message 1 of 4
IV10Sp3a How do I FillRegion a Rectangle

Not applicable
06-28-2007
12:53 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
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