OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 24-05-2012, 13:30
PAnderson PAnderson is offline
Member
 
Join Date: Nov 2003
Posts: 47
Question Paste at Node enhanced?

Awhile back Shelby gave this code for pasting an object at nodes, which is perfect if you have only one object to paste:

Code:
Sub PasteClipboardAtNodes()
    Dim s As Shape, sr As ShapeRange
    Dim sclip As Shape, n As Node

    Set sr = ActiveSelectionRange
    ActiveDocument.ReferencePoint = cdrCenter
    
    Set sclip = ActiveLayer.Paste

    For Each s In sr
        If s.Type = cdrCurveShape Then
            For Each n In s.Curve.Nodes
                sclip.Duplicate.SetPosition n.PositionX, n.PositionY
            Next n
        End If
    Next s
    
    sclip.Delete
End Sub
I would like to do something similar, only the selected objects are all different. For example, I might have a list of names, each name is a separate Artistic Text object, and I want to be able to select them all Copy and have them pasted at the nodes of the selected curve.

Ideally I would like to choose whether it pastes using the object center or its left, right, top or bottom center. Or maybe it could "respect" the relative center chosen (or object origin) prior to running the macro. Can this be done?

Patti
Reply With Quote
  #2  
Old 24-05-2012, 13:42
Joe Joe is offline
Member
 
Join Date: Nov 2008
Location: Latvia
Posts: 92
Send a message via Skype™ to Joe
Default

Sounds like something that I should add to this little docker I'm working on...

But back to your question - this is certainly doable. Adding the origin points and such instantly inflate the amount of work, but in general you would have to define a ShapeRange instead the single sclip shape, then define an index to set the amount of shapes. Like this:

Code:
Sub PasteClipboardAtNodes()
    Dim s As Shape, sr As ShapeRange
    Dim sclip As ShapeRange, n As Node

    Dim Index As Integer

    Set sr = ActiveSelectionRange
    ActiveDocument.ReferencePoint = cdrCenter
        
  Set sclip = ActiveLayer.PasteEx
    
    Index = 1

    For Each s In sr
        If s.Type = cdrCurveShape Then
            For Each n In s.Curve.Nodes
                sclip.Shapes(Index).Duplicate.SetPosition n.PositionX, n.PositionY
                If Index < sclip.Shapes.Count Then Index = Index + 1 Else Index = 1
            Next n
        End If
    Next s
    
    sclip.Delete
End Sub
In this example the shapes are being cyclically placed at the curve points, hope that helps.

EDIT: The PasteEx is important (I pasted a version without it), since it returns a range instead of a single shape.

Last edited by Joe; 24-05-2012 at 13:50.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy and paste as new document hvw Corel Photo-Paint VBA 2 01-02-2012 05:42
Paste special aakkaarr CorelDRAW/Corel DESIGNER VBA 3 22-04-2011 16:42
Paste to fit within page PAnderson CorelDRAW/Corel DESIGNER VBA 4 12-08-2010 15:25
Wireframe vs. Enhanced View bprice CorelDRAW/Corel DESIGNER VBA 2 19-01-2009 06:11
Delete Segment Enhanced Hernán New product ideas 1 08-12-2003 15:04


All times are GMT -5. The time now is 05:38.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com