Sub 建立虚拟物件()
Dim sr As New ShapeRange
Set s = ActiveVirtualLayer.CreateRectangle(0, 0, 5, 5)
sr.Add s
Set s1 = ActiveVirtualLayer.CreateRectangle(5, 5, 10, 10)
sr.Add s1
Set s2 = ActiveVirtualLayer.CreateRectangle(10, 10, 15, 15)
sr.Add s2
MsgBox "建立虚拟物件"
ActiveDocument.LogCreateShape s
MsgBox "建立虚拟物件Range"
ActiveDocument.LogCreateShapeRange sr
End Sub
🇺🇸 其他有关虚拟物件的资料
Unfortunately I don't think you can use it this way. All virtual shapes give you is quick transaction-less changes to the objects.
When you create a virtual shape, the whole process doesn't log any undo transactions and thus it is much faster.
Also many commands applied to virtual shapes do not log any transactions as well (moving, stretching objects, changing fills/outlines, etc).
However having said that, you must be extremely careful when using these,
since CorelDRAW has a lot of assumptions on what the state of the application should be at any given point.
If you change the state without informing the transaction manager of the change at some point,
this could destabilize the application and lead to all sorts of things, even crashes.
Normally the typical workflow of using virtual shapes would be:
Workflow A - tempoarary objects:
- Create virtual shape
- Change some properties
- Get some data (like size of the resulting object, or whatever)
- Delete the shape
Workflow B - creating objects quickly:
- Create virtual shape
- Change size, rotate, apply fill/outline
- Call Document.LogCreateShape to log the real shape creation transaction for undo purposes
Workflow C - editing existing objects:
- Make a copy of existing object (Shape.TreeNode.GetCopy().VirtualShape)
- Edit the copy (stretch/rotate, change fill/outline)
- Call OriginalObject.ReplaceWith(virtualShapeCopy) to log the actual transaction.
Anything else could result in potential problems.
Reply With Quote
🇨🇳 虚拟物件资料汉化版
所有虚拟形状所能提供的,是对对象进行快速的、不记录事务的更改。
当你创建一个虚拟形状时,整个过程不会记录任何撤销事务,因此速度非常快。
此外,许多应用于虚拟形状的命令也不会记录事务(例如移动、拉伸对象、改变填充/轮廓等)。
然而,话虽如此,使用虚拟形状时必须非常小心,因为 CorelDRAW 对于应用程序在任何给定时间点的状态有很多假设。
如果你在某些时候改变了状态而没有通知事务管理器,这可能会导致应用程序不稳定,甚至引发各种问题,包括崩溃。
通常使用虚拟形状的典型工作流程是:
工作流程 A - 临时对象:
创建虚拟形状
更改一些属性
获取一些数据(例如生成对象的大小,或其他)
删除形状
工作流程 B - 快速创建对象:
创建虚拟形状
改变大小、旋转,应用填充/轮廓
调用 Document.LogCreateShape 来记录实际的形状创建事务,便于撤销
工作流程 C - 编辑现有对象:
复制现有对象(Shape.TreeNode.GetCopy().VirtualShape)
编辑复制品(拉伸/旋转,改变填充/轮廓)
调用 OriginalObject.ReplaceWith(virtualShapeCopy) 来记录实际的事务
其他任何操作都可能导致潜在问题。