A DrawingView object is a 2-D representation of a 3-D part or assembly model. A drawing view is used to display design space geometry in document space. A view of design space is enclosed by the drawing view border (a handle that allows manipulation of the drawing view). Only one part or assembly document can be used as the basis for drawing views in a draft document.
DrawingViews in Visual Basic .NET |
Copy Code
|
Imports SolidEdgeFramework
Imports System.Runtime.InteropServices
Module Program
<STAThread()> _
Sub Main()
Dim objApplication As SolidEdgeFramework.Application = Nothing
Dim objDocuments As SolidEdgeFramework.Documents = Nothing
Dim objDraft As SolidEdgeDraft.DraftDocument = Nothing
Dim objSheet As SolidEdgeDraft.Sheet = Nothing
Dim objModelLinks As SolidEdgeDraft.ModelLinks = Nothing
Dim objModelLink As SolidEdgeDraft.ModelLink = Nothing
Dim objDrawingViews As SolidEdgeDraft.DrawingViews = Nothing
Dim objDrawingView As SolidEdgeDraft.DrawingView = Nothing
Try
OleMessageFilter.Register()
' Connect to a running instance of Solid Edge
objApplication = Marshal.GetActiveObject("SolidEdge.Application")
' Get a reference to the documents collection
objDocuments = objApplication.Documents
' Add a Draft document
objDraft = objDocuments.Add("SolidEdge.DraftDocument")
' Get a reference to the active sheet
objSheet = objDraft.ActiveSheet
' Get a reference to the model links collection
objModelLinks = objDraft.ModelLinks
' Add a new model link
objModelLink = objModelLinks.Add("C:\Part1.par")
' Get a reference to the drawing views collection
objDrawingViews = objSheet.DrawingViews
' Add a new drawing view
objDrawingView = objDrawingViews.AddPartView( _
objModelLink, _
SolidEdgeDraft.ViewOrientationConstants.igFrontView, _
1, _
0.1, _
0.1, _
SolidEdgeDraft.PartDrawingViewTypeConstants.sePartDesignedView)
' Assign a caption
objDrawingView.Caption = "My New Drawing View"
' Ensure caption is displayed
objDrawingView.DisplayCaption = True
Catch ex As Exception
Console.WriteLine(ex.Message)
Finally
OleMessageFilter.Revoke()
End Try
End Sub
End Module |
DrawingViews in C# |
Copy Code
|
using SolidEdgeFramework;
using System;
using System.Reflection;
using System.Runtime.InteropServices;
namespace SolidEdge.SDK
{
class Program
{
[STAThread]
static void Main(string[] args)
{
SolidEdgeFramework.Application application = null;
SolidEdgeFramework.Documents documents = null;
SolidEdgeDraft.DraftDocument draft = null;
SolidEdgeDraft.Sheet sheet = null;
SolidEdgeDraft.ModelLinks modelLinks = null;
SolidEdgeDraft.ModelLink modelLink = null;
SolidEdgeDraft.DrawingViews drawingViews = null;
SolidEdgeDraft.DrawingView drawingView = null;
try
{
OleMessageFilter.Register();
// Connect to a running instance of Solid Edge
application = (SolidEdgeFramework.Application)
Marshal.GetActiveObject("SolidEdge.Application");
// Get a reference to the documents collection
documents = application.Documents;
// Add a Draft document
draft = (SolidEdgeDraft.DraftDocument)
documents.Add("SolidEdge.DraftDocument", Missing.Value);
// Get a reference to the active sheet
sheet = draft.ActiveSheet;
// Get a reference to the model links collection
modelLinks = draft.ModelLinks;
// Add a new model link
modelLink = modelLinks.Add(@"C:\Part1.par");
// Get a reference to the drawing views collection
drawingViews = sheet.DrawingViews;
// Add a new drawing view
drawingView = drawingViews.AddPartView(
modelLink,
SolidEdgeDraft.ViewOrientationConstants.igFrontView,
1,
0.1,
0.1,
SolidEdgeDraft.PartDrawingViewTypeConstants.sePartDesignedView);
// Assign a caption
drawingView.Caption = "My New Drawing View";
// Ensure caption is displayed
drawingView.DisplayCaption = true;
}
catch (System.Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
OleMessageFilter.Revoke();
}
}
}
} |