3 Replies Latest reply on Oct 4, 2012 12:16 PM by CarlosCanto

    Create adobe illustrator rectangle script?


      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


      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

          sr.Add sRect
          sr.Add s
      End Sub