OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Corel User Forums > CorelDRAW > Macros/Add-ons

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 21-11-2010, 05:06
fungel
Guest
 
Posts: n/a
Default Corel Photopaint script available from Corel Draw?

Hi,

I recorded the script below in Photo-Paint. I would now like to run this directly from Corel Draw using the "Run Script" command.
Error comes up
"run-time error 1002
OLE automation error (you need an open document for this operation)"
Also then I think I would have problem with the Save function.

This all should save me from going "Edit Bitmap", running the script in PP, saving the document and closing PP. Does this make sense?

Any help would be appreciated.
I'm using X4.
Ta.
Fungel


REM Created in Corel PHOTO-PAINT Version 14.0.0.701
REM Created On Sunday, November, 21, 2010 by Administrator

WITHOBJECT "CorelPHOTOPAINT.Automation.14"
.ObjectSelectAll
.MaskCreate TRUE, 0, FALSE
.ObjectSelectNone
.ObjectSelect 1, TRUE
.EndMaskCreate
.MaskReduce 2
.MaskInvert
.EditClear 5, 245, 245, 245, 0
.FileSave CHR(7) + "C:+AFw-Documents and Settings+AFw-Administrator+AFw-Local Settings+AFw-Temp+AFw-Bitmap in Test.cdr.CPT", 1808, 0
END WITHOBJECT

I found this post and thought this might help: http://forum.oberonplace.com/showthr...ghlight=script

Last edited by fungel; 21-11-2010 at 05:48. Reason: Added post at the bottom which might be relevant
Reply With Quote
  #2  
Old 21-11-2010, 16:36
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Macro

I basically took the macro and ran it via VBA. It seems to work.
Code:
Sub Testing()
    With CorelScript
        .ObjectSelectAll
        .MaskCreate True, 0, False
        .ObjectSelectNone
        .ObjectSelect 1, True
        .EndMaskCreate
        .MaskReduce 2
        .MaskInvert
        .EditClear 5, 245, 245, 245, 0
        .FileSave "C:\temp\Test.CPT", 1808, 0
    End With
End Sub
Best of luck,

-Shelby
Reply With Quote
  #3  
Old 22-11-2010, 07:45
fungel
Guest
 
Posts: n/a
Default Nearly There

Hi,

I have now updated the code as below. The file gets exported and imported back in ok. The problem is that I cannot get Photopaint to actually remove a 2 pixel border around the edge of the graphic for some reason using the code I have... Can anyone help? I'm using X4.

Ta.
Fungel

Private Sub CommandButton69_Click()
Dim appDraw As New CorelDRAW.Application
Dim appPaint As New PHOTOPAINT.Application
Dim filter As CorelDRAW.ExportFilter
Dim docPP As PHOTOPAINT.Document
Dim docDRAW As CorelDRAW.Document
Dim sOrigBitmap As CorelDRAW.Shape, sNewBitmap As CorelDRAW.Shape
Dim x As Double, y As Double

ActiveDocument.BeginCommandGroup "ReducePixels"

If appDraw.ActiveShape.Type = cdrBitmapShape Then
Set sOrigBitmap = appDraw.ActiveShape
Set docDRAW = appDraw.ActiveDocument
sOrigBitmap.GetPosition x, y

Set filter = docDRAW.ExportBitmap("D:\temp\~temp.cpt", cdrCPT, cdrSelection, cdrRGBColorImage, 1835, 2252, 300, 300, cdrNormalAntiAliasing, False, True, False, False, cdrCompressionNone)
filter.Finish

Set docPP = appPaint.OpenDocument("D:\temp\~temp.cpt")
appPaint.CorelScript.ObjectSelectAll
appPaint.CorelScript.MaskCreate True, 0, False
appPaint.CorelScript.MaskReduce 5
appPaint.CorelScript.ObjectClip
appPaint.CorelScript.MaskRemove

docPP.SaveAs("D:\temp\~temp.cpt", cdrCPT).Finish

docPP.Close

docDRAW.ActiveLayer.Import "D:\temp\~temp.cpt"
Set sNewBitmap = appDraw.ActiveSelection
sNewBitmap.SetPosition x, y
sOrigBitmap.Delete
Kill "D:\temp\~temp.cpt"

ActiveDocument.EndCommandGroup
End If
End Sub
Reply With Quote
  #4  
Old 22-11-2010, 11:05
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Pixel Border

If the goal is to remove a 2 pixel border why send it to Photopaint to do this? You can just crop it by 2 pixels in Draw. Or did I miss something?

-Shelby
Reply With Quote
  #5  
Old 25-11-2010, 03:56
fungel
Guest
 
Posts: n/a
Default Pixel Thread

Hi Shelby,

I am trying to shrink the mask by 2 pixels around the inside of the graphic also. This is an underbase that I am trying to shrink so a simple crop is not suitable.

Does this make sense?

I have not found a method of doing this in Draw..

Ta.

Fungel
Reply With Quote
  #6  
Old 20-03-2012, 14:53
grzjanik grzjanik is offline
Member
 
Join Date: Mar 2010
Location: Lodz, Poland
Posts: 86
Send a message via Skype™ to grzjanik
Post Help please

Hi guys.

File ~temp.cpt is open in PP but nothing happens!?
Then the file is import corect in CD.

Selected section of code it does not work in PP, why?

Code:
Private Sub CommandButton69_Click()
 Dim appDraw As New CorelDRAW.Application
 Dim appPaint As New PHOTOPAINT.Application
 Dim filter As CorelDRAW.ExportFilter
 Dim docPP As PHOTOPAINT.Document
 Dim docDRAW As CorelDRAW.Document
 Dim sOrigBitmap As CorelDRAW.Shape, sNewBitmap As CorelDRAW.Shape
 Dim x As Double, y As Double

 ActiveDocument.BeginCommandGroup "ReducePixels"

 If appDraw.ActiveShape.Type = cdrBitmapShape Then
 Set sOrigBitmap = appDraw.ActiveShape
 Set docDRAW = appDraw.ActiveDocument
 sOrigBitmap.GetPosition x, y

 Set filter = docDRAW.ExportBitmap("D:\temp\~temp.cpt", cdrCPT, cdrSelection, cdrRGBColorImage, 1835, 2252, 300, 300, cdrNormalAntiAliasing, False, True, False, False, cdrCompressionNone)
 filter.Finish

 Set docPP = appPaint.OpenDocument("D:\temp\~temp.cpt")
 appPaint.CorelScript.ObjectSelectAll
 appPaint.CorelScript.MaskCreate True, 0, False
 appPaint.CorelScript.MaskReduce 5
 appPaint.CorelScript.ObjectClip
 appPaint.CorelScript.MaskRemove

 docPP.SaveAs("D:\temp\~temp.cpt", cdrCPT).Finish

 docPP.Close

 docDRAW.ActiveLayer.Import "D:\temp\~temp.cpt"
 Set sNewBitmap = appDraw.ActiveSelection
 sNewBitmap.SetPosition x, y
 sOrigBitmap.Delete
 Kill "D:\temp\~temp.cpt"

 ActiveDocument.EndCommandGroup
 End If
 End Sub
How to fix it?
Reply With Quote
  #7  
Old 27-03-2012, 08:48
grzjanik grzjanik is offline
Member
 
Join Date: Mar 2010
Location: Lodz, Poland
Posts: 86
Send a message via Skype™ to grzjanik
Post Draw to PhotoPaint

Hi,
can someone tell me what to do?

This is important for me.
~GrzJanik
Reply With Quote
  #8  
Old 30-03-2012, 00:15
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default PhotoPaint

Try this, and see if it does what you wish:

Code:
Set docPP = appPaint.OpenDocument("D:\temp\~temp.cpt")
appPaint.CorelScript.MaskSelectAll
appPaint.CorelScript.MaskReduce 25
appPaint.CorelScript.ImageCropToMask
appPaint.CorelScript.MaskRemove
Hopefully that helps,

-Shelby
Reply With Quote
  #9  
Old 30-03-2012, 08:22
grzjanik grzjanik is offline
Member
 
Join Date: Mar 2010
Location: Lodz, Poland
Posts: 86
Send a message via Skype™ to grzjanik
Post PhotoPaint

Thanks Shelby for Your help.

Your code is work, but...

appPaint.CorelScript.MaskSelectAll - creating rectangle mask of all.

I have one object with transparent.

I must create mask from object but i don't know how.

I'm trying:

appPaint.CorelScript.MaskCreate ????

but no results.

Please help.

Great thanks.

~GrzJanik

Last edited by grzjanik; 30-03-2012 at 08:24.
Reply With Quote
  #10  
Old 30-03-2012, 08:53
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Mask

Alright, try this version:
Code:
 Set docPP = appPaint.OpenDocument("D:\temp\~temp.cpt")
 docPP.Mask.SelectAll
 docPP.Mask.Reduce 5
 docPP.CropToMask
 docPP.Mask.Delete
Maybe it will work. :-)

-Shelby
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
Corel Trace and editing in Corel draw madhur General 1 26-09-2007 17:04
Corel PhotoPaint on C#/C++ lexcse General 1 27-07-2007 13:56
Type Mismatch error in Corel PhotoPaint V9 NEHovis Corel Photo-Paint VBA 2 17-07-2003 04:19
VBA script in Corel Draw 11 mikev CurveWorks 1 14-06-2003 08:59
Corel Capture 8 and Corel Script Helix CorelDRAW CS 0 13-12-2002 18:10


All times are GMT -5. The time now is 04:45.


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