주어진 정점으로 이루어진 Polygon을 해칭하는 예제입니다.
inData는 "HATCHPLINE,0,0,0.1,0,0.1,0.1,0,0.1,0,0," 이런식으로 주어지면 됩니다.
inData는 "HATCHPLINE,0,0,0.1,0,0.1,0.1,0,0.1,0,0," 이런식으로 주어지면 됩니다.
Private Sub drawHatchPline(ByVal inData As String)
Dim m_oShapeElement As ShapeElement
Dim m_Points() As Point3d
Dim ptrn As CrossHatchPattern
Dim vertices() As Point3d
Dim tokens() As String
Dim i As Integer, index As Integer
index = 0
tokens = Split(inData, ",")
ReDim Preserve m_Points(UBound(tokens) / 2)
For i = 1 To UBound(tokens)
m_Points(index) = Point3dFromXY(Val(tokens(i)), Val(tokens(i + 1)))
i = i + 1
index = index + 1
Next
Set m_oShapeElement = CreateShapeElement1(msv8Element, m_Points, msdFillModeNotFilled)
ActiveModelReference.AddElement m_oShapeElement
' Use a CrossHatchPattern object to set up the parameters for
' the hatching operation.
Set ptrn = CreateCrossHatchPattern(0.01, 0.01, Pi / 4, -Pi / 4)
vertices = m_oShapeElement.GetVertices
' SetPatternWithOrigin knows this is a cross hatch because the
' patterning parameters are being passed in a CrossHatchPattern
' object.
m_oShapeElement.SetPatternWithOrigin ptrn, vertices(2), Matrix3dIdentity
' Now save it to the file and display the pattern by redrawing
' the element
m_oShapeElement.Rewrite
m_oShapeElement.Redraw
End Sub
댓글
댓글 쓰기