Jump to content

hatch a region object - multiple areas


Tipo166

Recommended Posts

Hello All,

I need to hatch a region w/ multiple areas:

attachment.php?attachmentid=8797&stc=1&d=1229121988

 

Tried modding the example code for :

 
Public Function AddHatch(Region As AcadRegion) As AcadHatch
   ' This example creates an associative gradient hatch in model space.
   Dim patternName As String
   Dim PatternType As Long
   Dim bAssociativity As Boolean
   Dim outerLoop() As AcadEntity
   ReDim outerLoop(0)
   Dim oplineReg As AcadEntity
   Set oplineReg = Region.Copy
   Set outerLoop(0) = Region
   ' Define the hatch
   patternName = "CYLINDER"
   PatternType = acPreDefinedGradient '0
   bAssociativity = True
   
   ' Create the associative Hatch object in model space
   Set hatchObj = ThisDrawing.ModelSpace.AddHatch(PatternType, patternName, bAssociativity, acGradientObject)
   Dim col1 As AcadAcCmColor, col2 As AcadAcCmColor
   Set col1 = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.17")
   Set col2 = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.17")
   Call col1.SetRGB(255, 0, 0)
   Call col2.SetRGB(0, 255, 0)
   hatchObj.GradientColor1 = col1
   hatchObj.GradientColor2 = col2
   
   ' Append the outerboundary to the hatch object, and display the hatch
   hatchObj.AppendOuterLoop outerLoop
   hatchObj.Evaluate
   ThisDrawing.Regen True
End Function

 

invalid input here:

hatchObj.AppendOuterLoop outerLoop

 

obviously there is no "OuterLoop" but its really simple to hatch the object using the std autocad Hatch command and the options with it. Any ideas?

 

thanks,

trent

hatchobj.JPG

Link to comment
Share on other sites

  • 6 months later...
  • 4 weeks later...

did you try

Dim outerLoop(0) As AcadEntity

 

instead of

Dim outerLoop() As AcadEntity

ReDim outerLoop(0)

 

sometimes vba mistake from variant to other types...

Do you have this problem with every region or only some of them?

For me this kind of approach: appending loop - evaluating, always worked with closed objects (and a region is closed)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...