How to create projection view in the drawing using Creo VB API
In cad automation, automatically creating drawing from the model is one of the essential process to generate manufacturing drawing for production. Here this article is to demonstrate to generate projection drawing view from the general view using Creo VB API
Procedure
- Get session from the IpfcAsyncConnection
- Get model and drawing
- Set the location of projection view from general view
- List out all the drawing views from the drawing
- Find the general view from it name
- Create Projection view instructions
- Create Project View
Sample Code
Private Sub btn_CreateProjection_Click(sender As Object, e As RoutedEventArgs) Try BSession = AConnection.Session Model = BSession.CurrentModel Model2Ds = CType(Model, IpfcModel2D) Drawing = CType(Model, IpfcDrawing) Dim Location As New CpfcPoint3D Dim XVla As Double = 1.0 ' location x axis to place project view Dim YVal As Double = 1.0 'location y axis to place projection view Location.Set(0, XVla) Location.Set(1, YVal) Location.Set(2, 0.0) Dim ParentView As IpfcView2D Dim View2Ds As IpfcView2Ds = Drawing.List2DViews For i = 0 To View2Ds.Count - 1 Dim View2D As IpfcView2D = View2Ds.Item(i) If View2D.Name = tb_GeneralViewName.Text Then ParentView = View2D Dim CProjectionViewCreateInstruction As New CCpfcProjectionViewCreateInstructions Dim IProjectionViewCreateInstruction As IpfcProjectionViewCreateInstructions = CProjectionViewCreateInstruction.Create( ParentView, Location) Model2Ds.CreateView(IProjectionViewCreateInstruction) End If Next Catch ex As Exception MessageBox.Show(ex.ToString, "Failure") End Try End Sub