![]() |
#1
|
||||
|
||||
![]()
I wanted to try and use the new virtualshape in CorelDRAW X3 to basically store my original outline settings so that I could restore them after I made a couple changes to easily show a selection to a user (turning the outline thick, dotted and red). The problem I have run into is I see both shapes, if my original shape has a thick outline then I don't see my outline changes at all they seem to be covered by the virtualshape. Any help or comments would be great. Here is a little sample code of what I am trying to do:
Code:
Sub SelectObject() Dim Response Dim retval As Long, shift As Long Dim x As Double, y As Double Dim sel As Shape, selShape As Shape, sOrig As Shape MsgBox "No selection was found, Please click OK, then select a shape", , "Select Objects" Do While Response <> vbYes retval = ActiveDocument.GetUserClick(x, y, shift, 100, False, cdrCursorWinArrow) Set sel = ActiveDocument.ActivePage.SelectShapesAtPoint(x, y, False) If sel.Shapes.Count > 0 Then Set selShape = sel.Shapes(1) Set sOrig = selShape.TreeNode.GetCopy().VirtualShape sel.Outline.SetProperties 0.125, OutlineStyles(4), CreateCMYKColor(0, 100, 100, 0) Response = MsgBox("Is the dotted red object the shape you wanted to select?", vbYesNo, "Select Objects") If Response = vbYes Then selShape.ReplaceWith sOrig Else ActiveDocument.ClearSelection selShape.ReplaceWith sOrig MsgBox "Please click OK and try again to select the shape", , "Select Objects" End If End If Loop End Sub Shelby Last edited by shelbym; 27-03-2006 at 02:53. |
#2
|
||||
|
||||
![]()
Shelby,
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: 1. Create virtual shape 2. Change some properties 3. Get some data (like size of the resulting object, or whatever) 4. Delete the shape Workflow B - creating objects quickly: 1. Create virtual shape 2. Change size, rotate, apply fill/outline 3. Call Document.LogCreateShape to log the real shape creation transaction for undo purposes Workflow C - editing existing objects: 1. Make a copy of existing object (Shape.TreeNode.GetCopy().VirtualShape) 2. Edit the copy (stretch/rotate, change fill/outline) 3. Call OriginalObject.ReplaceWith(virtualShapeCopy) to log the actual transaction. Anything else could result in potential problems. |
#3
|
|||
|
|||
![]()
Sorry for bumping such an old topic, but a relevant question has popped up.
I finally managed to semi-understand the VS tech and all of a sudden certain parts of the code got 200 TIMES faster (For example creating and distributing 2500 objects in 0.17 seconds or so). Way cool! However I still have no idea how to create a Virtual Shape directly, without using the .GetCopy method. Currently my code looks like this: Code:
Set MakeShape = ActiveLayer.CreateRectangle2(0, 0, 1, 1) For Each Current In MakeShapeRange If Current.SizeWidth - Pad * 2 > 0 And Current.SizeHeight - Pad * 2 > 0 Then With MakeShape.TreeNode.GetCopy .VirtualShape.SetBoundingBox Current.LeftX + Pad, Current.BottomY + Pad, Current.SizeWidth - Pad * 2, Current.SizeHeight - Pad * 2 .LinkAsChildOf MakeShape.Layer.TreeNode MakeShapeRange.Add .VirtualShape End With End If Next Current MakeShape.Delete ActiveDocument.LogCreateShapeRange MakeShapeRange This seems cumbersome. As another problem if this gets Undo-ed the original shapes (presented as "Current" in the code above) disappear. So basically the question is how to properly create stand-alone Virtual Shapes, as mentioned in Alex's Workflow B example. Thanks in advance for any help. |
#5
|
||||
|
||||
![]()
Alex's beats me to the answer, but I will post mine also:
Code:
Sub CreateVirtualShape() Dim sVirtual As Shape Set sVirtual = ActiveVirtualLayer.CreateRectangle(0, 0, 5, 5) sVirtual.Fill.ApplyFountainFill CreateRGBColor(255, 0, 0), CreateRGBColor(255, 255, 0) sVirtual.Rotate 45 ActiveDocument.LogCreateShape sVirtual End Sub |
#6
|
|||
|
|||
![]()
Superb, thank you! This should improve pretty much every aspect of what I'm doing here.
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|