Skip to main content
Participating Frequently
October 4, 2012
Question

Create adobe illustrator rectangle script?

  • October 4, 2012
  • 1 reply
  • 1881 views

hi, this is a vba script that works in corel draw. I want it to work in illustrator instead but I don't know how to ammend it into javascript and adobe scripting language! Can anybody help??


what it does:

with an object selected
I run script
it creates
around the selected object a thin rectangle with a margin from the object of 0.05cm
then groups the object and rectangle togeather


thats it


Martin



Sub makeRect()

    Dim s As Shape, sRect As Shape
    Dim x As Double, y#, h#, w#
    Dim dMarg#
    Dim sr As New ShapeRange
  
    dMarg = 0.05
    ActiveDocument.Unit = cdrCentimeter
  
  
  
    Set s = ActiveShape
    If s Is Nothing Then Exit Sub
  
    s.GetBoundingBox x, y, w, h
  
    Set sRect = ActiveLayer.CreateRectangle2(x - dMarg, y - dMarg, w + (dMarg * 2), h + (dMarg * 2))
    sRect.Outline.Width = 0.001
  
  
  
    sRect.CreateSelection

    sr.Add sRect
    sr.Add s
    sr.Group
  
End Sub

This topic has been closed for replies.

1 reply

CarlosCanto
Community Expert
Community Expert
October 4, 2012

you could have continue asking in your previous post, it is the same topic...anyway, what's your programming expertise level? are you comfortable with VBA and Javascript?

Participating Frequently
October 4, 2012

I am basic level I can muddle through and change things in VBA, but I don't know anything about adobe scripting language I use illustrator all day everyday but I'm not a programmer.

Martin

CarlosCanto
Community Expert
Community Expert
October 4, 2012

ok, good, the options for you are

- if you have Excel or other Office application, and if you don't mind having Excel open and running your scripts from there then I can show you how to translate the corel script to illustrator using VBA, since you're more familiar with it.

- or start from scratch and translate the script to Javascript and run it directly from within Illustrator...it will need more effort on your part to understand the new language....

but either way at the end more beneficial to you, better yet if you learn both languages.