기본 콘텐츠로 건너뛰기

1월, 2013의 게시물 표시

Polygon 해칭

주어진 정점으로 이루어진 Polygon을 해칭하는 예제입니다. 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) ver

선택한 Text의 정보 출력

선택한 Text의 정보를 출력하는 예제입니다. Sub DisplaySelTextElement() Dim cim As CadInputMessage Dim oEnumerator As ElementEnumerator If Not ActiveModelReference.AnyElementsSelected Then ShowError "The macro requires a selection set" Exit Sub End If Set oEnumerator = ActiveModelReference.GetSelectedElements Do While oEnumerator.MoveNext Dim oElement As Element Set oElement = oEnumerator.Current If oElement.Type = msdElementTypeText Then ShowStatus oElement.AsTextElement.Text End If Loop End Sub

MSTN XM VBA - Lession4(요소 탐색하기)

아래 예제는 현재 열려 있는 모델의 요소에 접근하여 Range를 구하는 매크로 입니다. Sub EnumElements() Dim oScanEnumerator As ElementEnumerator Dim oElement As Element Set oScanEnumerator = ActiveModelReference.Scan Do While oScanEnumerator.MoveNext Set oElement = oScanEnumerator.Current If oElement.IsGraphical Then ShowStatus "Low = " & oElement.Range.Low.X & "," & oElement.Range.Low.Y ShowStatus "High= " & oElement.Range.High.X & "," & oElement.Range.High.Y End If Loop End Sub