shape pattern in corel draw vba

132 Views Asked by At

I want to make a patern of shapes based on the document size in corel draw. right now I have the four corners taken care of (dot1 to dot4). But, when my document size is bigger than 96" I need to put more than dots 1 to 4 so I've added the if statement but it' not quite what I want.

`

    ActivePage.CreateLayer ("CCD")
            Dim DOT1 As Shape
        Set DOT1 = ActivePage.ActiveLayer.CreateEllipse2(0.225, 0.225, 0.125, 0.125)
        DOT1.Fill.UniformColor.RGBAssign 0, 255, 255
        DOT1.Outline.SetNoOutline
            DOT1.Name = "DOT1"
            Dim DOT2 As Shape
        Set DOT2 = ActivePage.ActiveLayer.CreateEllipse2(DOCUMENTSIZEX - 0.225, 0.225, 0.125, 0.125)
        DOT2.Fill.UniformColor.RGBAssign 0, 255, 255
        DOT2.Outline.SetNoOutline
            DOT2.Name = "DOT2"
            Dim DOT3 As Shape
        Set DOT3 = ActivePage.ActiveLayer.CreateEllipse2(0.225, DOCUMENTSIZEY - 0.225, 0.125, 0.125)
        DOT3.Fill.UniformColor.RGBAssign 0, 255, 255
        DOT3.Outline.SetNoOutline
            DOT3.Name = "DOT3"
            Dim DOT4 As Shape
        Set DOT4 = ActivePage.ActiveLayer.CreateEllipse2(DOCUMENTSIZEX - 0.225, DOCUMENTSIZEY - 0.225, 0.125, 0.125)
        DOT4.Fill.UniformColor.RGBAssign 0, 255, 255
        DOT4.Outline.SetNoOutline
            DOT4.Name = "DOT4"
'check the size of the document, if bigger than 96 inches it will add 2 more dots
      
        If DOCUMENTSIZEX > 96 Then
            Dim DOT5 As Shape
        Set DOT5 = ActivePage.ActiveLayer.CreateEllipse2(DOCUMENTSIZEX / 2, DOCUMENTSIZEY - 0.225, 0.125, 0.125)
        DOT5.Fill.UniformColor.RGBAssign 0, 255, 255
        DOT5.Outline.SetNoOutline
            DOT5.Name = "DOT5"
            Dim DOT6 As Shape
        Set DOT6 = ActivePage.ActiveLayer.CreateEllipse2(DOCUMENTSIZEX / 2, 0.225, 0.125, 0.125)
        DOT6.Fill.UniformColor.RGBAssign 0, 255, 255
        DOT6.Outline.SetNoOutline
            DOT6.Name = "DOT6"
        End If

`

I've tried the duplicate function "set dot7=dot5.duplicate" type thing which is only doing it once and I'd like to have it make a variable about of dots (only and only if the document is over 96" by multiple of 48). ie: if the document is 144" there would be one every 48"

I've added a portion of the code bellow and I'm mostly looking for a hint at what function I should look at in order to play arround with it and learn it.

thanks

1

There are 1 best solutions below

0
On BEST ANSWER

Not the most elegant solution I'm sure but, that's what I got and it works.

'CREATING THE DOTS
If Len(TextBox27.Value) = 0 Then
If CheckBox8.Value = False Then
        ActivePage.CreateLayer ("CCD")
        Dim DOT1 As Shape
    Set DOT1 = ActivePage.ActiveLayer.CreateEllipse2(0.225, 0.225, 0.125, 0.125)
    DOT1.Fill.UniformColor.RGBAssign 0, 255, 255
    DOT1.Outline.SetNoOutline
        DOT1.Name = "DOT1"
        Dim DOT2 As Shape
    Set DOT2 = ActivePage.ActiveLayer.CreateEllipse2(DOCUMENTSIZEX - 0.225, 0.225, 0.125, 0.125)
    DOT2.Fill.UniformColor.RGBAssign 0, 255, 255
    DOT2.Outline.SetNoOutline
        DOT2.Name = "DOT2"
        Dim DOT3 As Shape
    Set DOT3 = ActivePage.ActiveLayer.CreateEllipse2(0.225, DOCUMENTSIZEY - 0.225, 0.125, 0.125)
    DOT3.Fill.UniformColor.RGBAssign 0, 255, 255
    DOT3.Outline.SetNoOutline
        DOT3.Name = "DOT3"
        Dim DOT4 As Shape
    Set DOT4 = ActivePage.ActiveLayer.CreateEllipse2(DOCUMENTSIZEX - 0.225, DOCUMENTSIZEY - 0.225, 0.125, 0.125)
    DOT4.Fill.UniformColor.RGBAssign 0, 255, 255
    DOT4.Outline.SetNoOutline
        DOT4.Name = "DOT4"

'check the size of the document, if bigger than 96 inches it will add more dots

    
If DOCUMENTSIZEX > 96 Then

' Create a temp layer for the dots
ActivePage.CreateLayer ("CCD 2")

Dim SEP As Double
Dim DOCXINT As Long
Dim DOCX As Double
Dim OFFSETP As Double

' Math to calculate how many dots and where to place them
DOCXINT = Int(DOCUMENTSIZEX / 48) - 1 'set the number of times the dots needs to be created in the middle
DOCX = DOCUMENTSIZEX / 48
SEP = DOCUMENTSIZEX / Int(DOCUMENTSIZEX / 48)
OFFSETP = DOCUMENTSIZEX / Int(DOCUMENTSIZEX / 48)

' Create DOT5
Dim DOT5 As Shape
Set DOT5 = ActivePage.ActiveLayer.CreateEllipse2(SEP, DOCUMENTSIZEY - 0.225, 0.125, 0.125)
DOT5.Fill.UniformColor.RGBAssign 0, 255, 255
DOT5.Outline.SetNoOutline
DOT5.Name = "MidDotTop"

' Create DOT6
Dim DOT6 As Shape
Set DOT6 = ActivePage.ActiveLayer.CreateEllipse2(SEP, 0.225, 0.125, 0.125)
DOT6.Fill.UniformColor.RGBAssign 0, 255, 255
DOT6.Outline.SetNoOutline
DOT6.Name = "MidDotBottom"


' Create dots in the middle of the CCD
ActivePage.ActiveLayer.Shapes.All.CreateSelection

' Duplicates the dots based on the width
For t = 1 To DOCXINT - 1
    ActiveSelection.DuplicateAsRange (SEP)
    ActiveShape.Name = "MidDot" & t
    SEP = SEP + OFFSETP
Next t

'copies the dots the the CCD layer


 ActivePage.ActiveLayer.Shapes.All.CreateSelection

ActiveDocument.Selection.MoveToLayer 
ActivePage.Layers("CCD")

' Delete the temp layer
ActivePage.Layers("CCD 2").Delete


End If