Product : Engine, Version : 5.1.1.1037, ArticleID : 41023981

HowTo : Create a polyface with holes

Article41023981
TypeHowTo
ProductEngine
Version5.1.1.1037
Date Added5/23/2005
Submitted byMassimo Schinardi
Keywords

Subject

Create a polyface with holes

Summary

How can I create a solid object (vdPolyface) with a "hole" in it (using VisualBasic 6)?

Solution

See this sample code :
    Dim rect1 As vdRect
    Dim rect2 As vdRect
    Dim circle1 As vdCircle
    Dim points As Variant
    Dim hatch As vdPolyhatch
    Dim pface As vdPolyface
    
    'Creation of the entities that will define the shape of the polyface
    Set rect1 = vd.ActiveDocument.ActiveLayOut.Entities.AddRect(Array(0, 0, 0), 20#, 10#)
    Set rect2 = vd.ActiveDocument.ActiveLayOut.Entities.AddRect(Array(12, 3, 0), 5#, 5#)
    Set circle1 = vd.ActiveDocument.ActiveLayOut.Entities.AddCircle(Array(6, 5, 0), 4#)
    
    
    Set hatch = vd.ActiveDocument.ActiveLayOut.Entities.AddPolyHatch
    'split the rect1 to 64 points
    points = rect1.GetSamplePoints(64, 0)
    'add a polyhatch from the points that produced from the first rectangle
    hatch.AddPolyPath 0, points
    
    'split the rect2 to 64 points
    points = rect2.GetSamplePoints(64, 0)
    'add a polyhatch from the points that produced from the second(inner) rectangle
    hatch.AddPolyPath 16, points
    
    'split the circle to 64 points
    points = circle1.GetSamplePoints(64, 0)
    'add a polyhatch from the points that produced from the circle
    hatch.AddPolyPath 16, points
    
    'deletion of the entities that no longer needed
    rect1.Erase
    rect2.Erase
    circle1.Erase
    
    hatch.FillMode = VdFillModeSolid
    hatch.Thickness = 4#
    
    'Creation of a polyface from another object (vdpolyhatch) through "GetPolyFace" function
    Set pface = hatch.GetPolyFace(64)
    'Adds the polyface to the activelayout
    vd.ActiveDocument.ActiveLayOut.Entities.AddItem pface
    'Erases the polyhatch
    hatch.Erase
    
    vd.CommandAction.Zoom "e", 0, 0
    vd.CommandAction.View3D "shadeon"
    vd.CommandAction.View3D "VINE"