See the Manifold web site for scripting examples that may be published from time to time in addition to those below.
.NET Language Examples
Manifold may be programmed in .NET languages such as VB .NET or C#. Some elementary examples follow.
Example
Display all drawings found in the active project using VB .NET:
Imports Manifold.Interop
Imports Manifold.Interop.Scripts
Imports Microsoft.VisualBasic
Class Script
Shared Sub Main
Dim doc As Document = Context.Application.ActiveDocument
Dim cmp As Component
Dim rpt As String = ""
' traverse all components and add name of each drawing to
' report
For Each cmp In doc.ComponentSet
If cmp.Type = ComponentType.ComponentDrawing Then
If rpt <> "" Then
rpt = rpt & vbCrLf
End If
rpt = rpt & cmp.Name
End If
Next
' check if there are no drawings
If rpt = "" Then
rpt = "No drawings."
End If
Context.Application.MessageBox(rpt, "Script")
End Sub
End Class
Example
Do the same using C#:
using System;
using Manifold.Interop;
using Manifold.Interop.Scripts;
class Script {
static void Main() {
Document doc = (Document)Context.Application.ActiveDocument;
String rpt = "";
// traverse all components and add name of each drawing to
// report
foreach (Component cmp in doc.ComponentSet) {
if (cmp.Type == ComponentType.ComponentDrawing) {
if (rpt != "")
rpt = rpt + "\n";
rpt = rpt + cmp.Name;
}
}
// check if there are no drawings
if (rpt == "")
rpt = "No drawings.";
Context.Application.MessageBox(rpt, "Script");
}
}
Example
Create a new drawing and populate it with a point object using VB .NET:
Imports Manifold.Interop
Imports Manifold.Interop.Scripts
Class Script
Shared Sub Main
Dim app As Application = Context.Application
Dim doc As Document = app.ActiveDocument
' create new drawing
Dim drw As Drawing = doc.NewDrawing("New Drawing")
' create new point and then new object
Dim pnt As Point = app.NewPoint(10, 20)
Dim pntGeom As Geom = app.NewGeom(GeomType.GeomPoint, pnt)
drw.ObjectSet.Add(pntGeom)
' open created drawing
drw.Open
End Sub
End Class
See Also
See the manifold.net web site for additional scripting examples.