Document Unit Conversion- ParseUnit and Format Unit methods of the UnitsOfMeasure object.
View Coordinate Conversion- ViewToSheetViewToSheetViewToSheetViewToSheetViewToSheet and SheetToView methods of the DrawingView object.
2D to 3D Conversion- Convert2DCoordinate method of the Profile object.
3D to 2D Transformations- ModelToView method of the DrawingView object.
Assembly Transformations- GetMatrix and PutMatrix methods of the Occurrence object.
Model to Drawing View Conversion
This part of the conversion and transformation series discusses a case where a hole exists in the part model and its center point in the drawing views need to be found in terms of the sheet or document units.
The case is illustrated in this image:
The hole is created in the ordered mode and has a profile which can be accessed as below:
Dim seApp As SolidEdgeFramework.Application =
Dim sePartDoc As SolidEdgePart.PartDocument = seApp.ActiveDocument
Dim seHole As SolidEdgePart.Hole = sePartDoc.Models.Item(1).Holes.Item(1)
Dim seHoleProfile As SolidEdgePart.Profile = seHole.Profile
The center point of the profile is a 2d point since a profile is essentially in a 2d plane:
Dim xHole As Double, yHole As Double
The center point needs to be converted to a 3d point since the hole is in 3D space on the model.
Here comes our first conversion:
Dim xHole3D As Double, yHole3D As Double, zHole3D As Double
seHoleProfile.Convert2DCoordinate(xHole, yHole, xHole3D, yHole3D, zHole3D)
This gives the hole’s center point in 3D space as illustrated in the image above.
The target is to locate the same point on a sheet where the drawing views of the model are placed as shown below:
This calls for the second conversion from model to view and happens in the Draft document:
Dim seDraftDoc As SolidEdgeDraft.DraftDocument = seApp.ActiveDocument
Dim seSheet As SolidEdgeDraft.Sheet = seDraftDoc.ActiveSheet
Dim seView As DrawingView = seSheet.DrawingViews.Item(1)
Dim xView As Double, yView As Double, xSheet As Double, ySheet As Double
seView.ModelToView(xHole3D, yHole3D, zHole3D, xView, yView)
This converts the 3d coordinate to the 2d equivalent in the draft’s view but not yet on the sheet in terms of the draft document’s units.
This is done in the 3rd conversion where the view coordinates are converted to sheet coordinates as explained in the previous episode of this series.
seView.ViewToSheet(xView, yView, xSheet, ySheet)
This completes the conversion of a hole’s center point from the 3D model to the 2D sheet.
The next part will show how to perform matrix manipulations on occurrences to move and rotate them in the assembly environment.