|
 |  | Document
|
Document Object
See also: Using the Document Object.
| |

 |
BeginOperation method ( OpName As String ).
The BeginOperation method opens an operation bracket.
OpName The name for a group of operations between BeginOperation and EndOperation calls.
After an operation bracket is open, each modification of the document interprets as a part of a single group operation, until the last balanced EndOperation method is called.
The following VBScript macro adds a red box to the document.
BeginOperation "Adding Red Box"
Set sh = RootNodes.Add("Shape")
sh("appearance") = "Appearance"
sh("appearance")("material") = "Material"
sh("appearance")("material")("diffuseColor") = Array(1, 0, 0)
sh("geometry") = "Box"
EndOperation
|
|


| |

 |
CurrentContext property, read-only, Object.
Returns a Proto object that represents the current PROTO context (namespace) at the caret position in Editor window or the context of the selected item in Scene Tree pane. Returns Nothing, if the caret position is in the global (default) context.
|

| |

 |
CurrentEntity property, read-only, Object.
Returns an Entity object that represents the current node, field, PROTO declaration or route at the caret position in Editor window or the selected item in Scene Tree pane. Returns Nothing, if there is no selected entity.
The following VBScript macro prompts about entity type at the caret position in Editor window or the current selection in Scene Tree pane.
Set e = CurrentEntity
If e Is Nothing Then
MsgBox "Nothing"
Else
Select Case e.EntityType
Case vpNode, vpNodeRef
MsgBox "Node " & e.TypeName
Case vpField, vpFieldDecl, vpProtoURL
MsgBox "Field " & e.Name
Case vpProto, vpExternProto
MsgBox "Proto " & e.Name
Case vpRoute
MsgBox "Route from " & e.FromField.Name
End Select
End If
|
|

| |

 |
CurrentResource property, read-only, String.
Returns a full pathname of the resource file, currently selected in Resource View or File List. Returns an empty string, if both Resource View and File List are inactive (have no keyboard focus), or no filename is selected, or nonlocal URL is selected in Resource View.
|

| |

 |
EnableModeless method ( Enable As Boolean ).
Enables or disables existing modeless windows in VrmlPad.
Enable A Boolean that specifies whether VrmlPad should enable or disable its modeless windows. Possible values are:
True - Enables all modeless windows, returning VrmlPad to its normal state. Use this after an add-in has dismissed its modal dialog.
False - Disables all modeless windows. Use this before an add-in displays a modal dialog.
Add-ins typically use EnableModeless to disable modeless windows before displaying a modal dialog so that the user cannot click the windows while the dialog is showing.
The following example reports the count of a TimeSensor nodes in the document.
doc.EnableModeless False
MsgBox doc.StdProtos("TimeSensor").Count
doc.EnableModeless True
|
|

| |

 |
EndOperation method.
The EndOperation method closes an operation bracket, opened by the BeginOperation method.
|

| |

 |
FileName property, read-only, String.
Gets the full path to the file containing the document, for example: "C:\MyScenes\Home.wrl". Returns empty string for a new unsaved document.
|

| |

 |
Name property, read-only, String.
Gets the name of the current document, for example "Home.wrl". Returns empty string for a new unsaved document.
|

| |

 |
NewFile method ( [SaveChanges] ).
Closes the active document and creates a new empty document (with VRML header).
SaveChanges (Optional) An enum of type VpSaveOptions that indicates whether to save changes to a document before closing it. Following are the possible values, which have the Long type:
- vpPromptToSaveChanges = 0 (the default)
Prompts the user to save changes. If the user cancels the SaveAs dialog, NewFile method fails.
- vpDoNotSaveChanges = 1
Does not save changes, and does not prompt the user.
- vpSaveChanges = 2
Saves all changes and does not prompt the user.
|

| |

 |
NewMatrix method ( [Init] ) As Object.
Returns a new VrmlMatrix object.
Init (Optional) An array of 12 or less single-precision floating-point values specified matrix, stored in column-major order, or a Node object that represents Transform or Viewpoint node.
By default, the method creates an identity matrix.
See also: Matrix property of the Node object.
|

| |

 |
NewSubdocument method ( [URL] ) As Object.
Creates a new or opens an existing subdocument. Returns the Document object, that represents a new subdocument.
URL (Optional) A String that specifies the URL or the full path to the existing VRML file. If a subdocument with the specified URL already opened, the method returns a new reference to this subdocument.
By default, the NewSubdocument method creates a new empty subdocument.
The following VBScript macro creates an Inline node, that refers to a Shape node.
Set inline = RootNodes.Add("Inline")
inline("url") = "shape.wrl"
Set subdoc = NewSubdocument
subdoc.RootNodes.Add "Shape"
subdoc.Save ConvertURL(inline("url")(1))
|
|

| |

 |
Nodes property, default, read-only, Object.
Returns a Nodes collection of all nodes in the global context given a name using the DEF keyword.
This collection is read-only, use the RootNodes property to add a new node to the document.
The following example refers a node named "L1".
Set node = Document("L1")
|
|

| |

 |
OpenFile method ( FileName As String, [SaveChanges] ).
Closes the active document and opens a document with a specified file name.
FileName A String that specifies the full path to the document.
SaveChanges (Optional) An enum of type VpSaveOptions that indicates whether to save changes to a document before closing it. Following are the possible values, which have the Long type:
- vpPromptToSaveChanges = 0 (the default)
Prompts the user to save changes. If the user cancels the SaveAs dialog, OpenFile method fails.
- vpDoNotSaveChanges = 1
Does not save changes, and does not prompt the user.
- vpSaveChanges = 2
Saves all changes and does not prompt the user.
|

| |

 |
Protos property, read-only, Object.
Returns a Protos collection of all PROTO declarations available from the global context.
The following example creates an empty PROTO and instanciates it.
Set proto = Document.Protos.Add("Avatar")
Set node = Document.RootNodes.Add(proto)
|
|

| |

 |
Range property, read-only, Object.
Returns a Range object that represents text range from the beginning to the end of the document. For information about Range objects, see Using the Range Object.
|

| |

 |
ReadOnly property, read/write, Boolean.
True if changes to the document cannot be saved to the original document.
This example saves the document if it isn't read-only.
If Document.ReadOnly = False Then Document.Save
|
|

| |

 |
RootNodes property, read-only, Object.
Returns a Nodes collection of root nodes of the document.
The following example adds a node to the end of the document.
Set node = Document.RootNodes.Add("Transform")
|
|

| |

 |
Routes property, read-only, Object.
Returns a Routes collection of all ROUTEs in the global context.
The following Visual Basic example removes all routes to a node labeled "L1".
Dim r As Route
For Each r In Document.Routes
If r.ToNode.Name = "L1" Then r.Delete
Next
|
|

| |

 |
Save method, ( [NewFileName], [Compressed] ).
Saves the document.
NewFileName (Optional) A String that specifies the name for the document. If a document with the specified NewFileName already exists, the document is overwritten without the user being prompted first.
By default, the document saves to the previous location. If the document hasn't been saved before, the Save As dialog box prompts the user for a file name.
Compressed (Optional) A Boolean that indicates whether to save the document being compressed or not. If True, the document will be compressed before saving with the default compression level.
By default, the document keeps the previous compression status.
|

| |

 |
Saved property, read/write, Boolean.
Gets a document's saved status — indicating whether a document has changed since it was last saved.
True if the document hasn't changed since it was last saved. False if VrmlPad displays a prompt to save changes when the document is closed.
|

| |

 |
Selection property, read-only, Object.
Returns a Range object that represents a selected range or the insertion point.
The following example replaces selection with a text.
Document.Selection = "Some Text"
|
|

| |

 |
StdProtos property, read-only, Object.
Returns a Protos collection of all standard node types. The collection is read-only, so you can't add new items to the collection or change existing items.
The following example counts all Shape nodes in the document.
MsgBox Document.StdProtos("Shape").Instances.Count
|
|

| |

 |
URLs property, read-only, Object.
Returns a Fields collection of all document URL fields and EXTERNPROTO pseudo-fields. URL field is a field (or exposedField) declaration or definition of type MFString, having in it's name substring "url".
The following example replaces URL "a.gif" on "b.gif" across the document.
For Each f In Document.URLs
For i = 1 To f.Count
If f(i) = "a.gif" Then f(i) = "b.gif"
Next
Next
|
|

| |

 |
Window property, read-only, Object.
Returns a Window object that represents VrmlPad application's main window.
|

|
|
|