Illustrator Scripting :: Create JS Script To Move Objects Away From Common Center Based Upon Their Current Position

Jan 17, 2014

I was hoping to create a JS script to move objects away from common center based upon their current position. I was thinking to use a single selected path item as the center based on its position x/y and width/height. Using this reference point the script would then move away all other path items from this center point based on a desired amount and with uniform increments given their current location from this center. I was thinking cos and sin would be my friend in this case, however they seem to have become my foe instead. ;-)
 
Does this sound doable? What am I missing, doing wrong, misinterpreting? Below is a non-working attempt, I can't seem to sort things out, perhaps I was close and missed it or maybe I am super way off and its more complex than I thought. However at this point I am confused across my various failed attempts this only being one of them. 
 
// Example failed code, nonworking concept
var docID = app.activeDocument;
var s0 = docID.selection[0];
pID = docID.pathItems;
var xn, yn;
var stepNum = 20;

[Code]....

View 13 Replies


ADVERTISEMENT

Illustrator Scripting :: How To Center Current Selection To Artboard

Feb 17, 2014

how do I center my current selection to the artboard? just like hitting the "horizontal align-center" and "vertical align-center" buttons. I've been searching for the last two hours and before my head hits the keyboard.
 
What I'm struggling with: in my init function i create a new document and then copy all layers from the previous document step by step to the new document and then save it as SVG.
 
// Init
(function(){
          destination = Folder.selectDialog('Select folder for SVG files.', docPath);
          if (!destination){return;}
          holderDoc = app.documents.add();
          stepThroughAndExportLayers(docRef.layers);
}());
 
my problem is that holderDoc = app.documents.add(); always creates a document that is not the same size as my initial document where the layers get copied from.
 
so I want the exact same artboard size as in my initial document.I'm fine with either doing it as fixed values or taking directly the values of the inital doc. i tried this in the segment where I create the new document:
 
// Init
(function(){
  destination = Folder.selectDialog('Select folder for SVG files.', docPath);
  if (!destination){return;}
  holderDoc = app.documents.add();
  holderDoc.artboards[0].artboardRect = [0,0,128,128];
  stepThroughAndExportLayers(docRef.layers);
}());
 
and get this error message: "Error 1200: an Illustrator error occured: 1346458189 ('PARM')

Line: 83
-> holderDoc.artboards[0].artboardRect = [0,0,128,128];"
 
which from what I've read on the web means that illustrator doesnt know what document to pick. but i have called it directly. I do not want to fit the artboard to the images/layer. the artboard should always have a certain size. (for me 128px by 128px)
 
// edit: workaround
(function(){
          destination = Folder.selectDialog('Select folder for SVG files.', docPath);
          if (!destination){return;}
          var activeArtboard = app.activeDocument.artboards[app.activeDocument.artboards.getActiveAr tboardIndex()];
          var ABRect = activeArtboard.artboardRect;
          holderDoc = app.documents.add();
          holderDoc.artboards.add(ABRect);
          holderDoc.artboards.remove(0);
          holderDoc.artboards.setActiveArtboardIndex(0);
          //stepThroughAndExportLayers(docRef.layers);
}());
 
i now added a new artboard to the new document with the same size as the artboard on the initial document.i remove the predefined artboard on the new doc and set the new artboard as active the artboard is now not centered into the window. which lets illustrator place my image with ctrl+c -> ctrl+v somewhere outside the artboard.
 
i now need to align my selection to the center of the artboard. but i cant find any reference on how to center a selection to the artboard.

View 7 Replies View Related

Illustrator :: Move Dialog Box - Start With Values Set At Current Position?

Jul 17, 2012

With an object selected and the Selection tool active, I press Return to get the Move dialog box.
 
For some reason, there seem to be random values entered in the Horizontal and Vertical fields. Instead, I just want the boxes to always start at 0 so that I can decide where it moves, instead of having to clear these fields manually.
 
how to get this box to behave as I want it to?

View 3 Replies View Related

3ds Max :: Move Objects And To Create In Other Position

May 4, 2011

I have these problems.

1. when I creat a new object he stays at position 0,0,0 and I only can move when I transform in some editable.
2.this happend when I try to construct bones TOO, and I can create whitohou the zeros point, when I click the bones are creating in same point in viewport.

I all ready try to press x, see the snap toogle, dont like to be an Axis constrain, try to restar to default config.

View 2 Replies View Related

Illustrator Scripting :: Copy And Paste Position And Size Of Two Different Objects?

Sep 20, 2012

how can I copy and paste position and size of two objects?
 
Let's say I have a circle 2 x 2 cm and it's position is y 5cm x 5cm, I have a square of size 3 x 7 cm and it's position is y 0cm x 0cm.
 
How do I copy and paste in a single command/step the circles position and size to square, so I can get square of 2 x 2 cm and it's position 5cm x 5cm?
 
Something like copy + paste in place with a different logics. I hope You understand what I want.
 
I'm doing it now manually, I'm copying size and position of one object to another [ctrl + c > ctrl + v] but it takes quiet a while,

View 2 Replies View Related

3ds Max Modeling :: Changing Position Of Objects Towards Center

Jan 27, 2014

How to change position of several objects toward center (let's say all objects have pivot point in one place) ?

View 4 Replies View Related

AutoCAD Inventor :: Create Parts List Macro - Position Based On Style

Oct 19, 2011

I have a macro that I acquired somewhere (possibly these boards, can't remember now) for placing a parts list.  I have modified it somewhat to change the location on the sheet where the list gets placed, as well as a sub that starts the autoballoon command afterward.

The macro is set up to place the parts list in the upper left corner, by adding the parts list width to the Mini Point of the border.  This works perfectly well, except that we have two parts list styles, and they are differently sized.

What I would like to do is have the macro detect the parts list style, and change the offset value depending on which style it finds.  I am an extreme novice with the API, who basically knows just enough to tweak sample code a bit, and have not been able to find anything close enough to use as an example.

How I should go about this, or even post some samples of something similar?  Current code is shown below.
 
Public Sub CreatePartsList() On Error Resume Next ' Set a reference to the drawing document. ' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument 'Set a reference to the active sheet. Dim oSheet As Sheet Set oSheet = oDrawDoc.ActiveSheet ' Set a reference to the first drawing view on ' the sheet. This assumes the first drawing ' view on the sheet is not a draft view. Dim oDrawingView As DrawingView Set oDrawingView = [code].......

The macro does not have to set the parts list style - that is controlled by the drawing Standard.  It just needs to detect what it is, and place the list accordingly. 

View 7 Replies View Related

Illustrator :: Z Order Based On Relative Position

Jul 16, 2013

I am using multiple objects to make larger more complex objects. As part of this I need a way to select a large group of objects and adjust their Z Order. For example, say I have a grid of 100 squares, 10 columns of 10 squares. I want to arrange them so the squares (rows) toward the bottom of the grid are in front (bring to front/bring forward) the squares that are higher up in the grid. Basically, every row should be further back in the Z order than the row below it.
 
Now you might say well for a grid this is simple just select every object/square in the row and move them forward or back as needed. But in my case they are not actually arranged in a neat grid, they are pretty randomly thrown together. But the requirement is still the same, I want to take all of the objects and arrange them so the objects that are closer to the bottom of the art board are further forward in the Z order than the objects above them. Basically think of the bottom of the artboard as being the front most row of the Z order and the top of the art board as the furthest back in the Z order. I use this type of configuration to give the perception of depth and form.

Below you can see an example of a cloud like graphic created using this technique by manually adjusting each individual object which takes forever on larger objects. I pick a point toward the bottom, and then I manually start adjusting Z order on each item until I get the effect I want. Having some way to pick a point on the art board and then arrange the objects above and below it on the Y axis by moving them forward or back in the Z order as needed would save me a ton of time. As you can see below, from about the 3rd or fourth row of squares from the bottom, I have brought those to the front, and each row above or below it has had it's Z order adjusted to give the impression of depth. Each consecutive row after the foreground row is progressively further back in the Z order. Any way to automate this so that I can atleast have a base to start with before I start doing my manual adjustments?

View 6 Replies View Related

AutoCad :: Routine To Move Objects To Absolute 0 / 0 Position

Jan 21, 2014

So I have a lot of 2D drawings (a couple thousand roughly) that I need to go through and shift the objects within to the absolute 0,0 position. That way, when we insert them into a new drawing, everything is centered appropriately and not way off the screen.

Instead of:
Open File > Select Objects > "MOVE" > Specify Basepoint > " * 0 , 0 " > Center View on Newly position Objects > Save File > Close File
... Repeat ...

By way of a LISP routine, or a script that could automatically do the above steps on it's own. Even something that doesn't require me to hit *, then tab, then 0, then tab, then 0 again.

View 9 Replies View Related

Illustrator Scripting :: Hide Layers Based On List?

Apr 8, 2011

I have a very complex graphic with many elements and I would like to find a way to hide layers based on a list.  In the documentation that there is a way to tell if a layer is hidden, but didn't see anything about a way to actually to control the hide/unhide property.  Is this possible?

View 15 Replies View Related

Illustrator Scripting :: Select All Items In Document Based On SpotColor?

Jun 28, 2012

I'm trying to select every object with the color "CutContour" So far I've been trying:
 
myDoc.selection = myDoc.spots.getByName("CutContour"); I guess this obviouslly wouldn't work though because myDoc.selection is looking for an array of objects. However, I can't figure out how to loop through all the objects in the document and check to see if they contain the SpotColor.
 
I want to use the Select > Same > Stroke Color , but I heard that using that in Javascript isn't available unless you have CS6 (which I currently don't). Is it true that accessing menu items through scripting is a feature in CS6?

View 4 Replies View Related

Illustrator Scripting :: Get Position Of Selected Object

Oct 4, 2012

is there a way to get position of any selected object? It seems like normally you have to dive into specific item like textFrames to get position, but was curious if there was a generic way of doing this for selected objects.

View 5 Replies View Related

Illustrator Scripting :: Resetting Anchor Position Of TextFrameItem?

Feb 21, 2012

Why does this not work? The textFrameItem.anchor behaves as if it is a read only value but it isn't supposed to be. What am I doing wrong?
 
function pointText(onLayer,str){
    var pointText = onLayer.textFrames.add();
    pointText.contents = str;[CODE].....

View 1 Replies View Related

Illustrator Scripting :: How To Check Color Profile For Current Document

Oct 16, 2012

I'd like to create a script that checks the current document's color profile and checks it against a string, for example "sRGB IEC61966-2.1". My studio has a script that performs various functions to make sure that all the layers are visible/unlocked, checks for stray points, etc., and we'd like to add a check to the color profile because we handle a large number of files and this setting is overlooked a lot.
 
It's alright if this value isn't writable through script (we can just pop up an alert letting the user know that they need to change it), but I can't find where to actually read this setting! We're currently working on Macs and with JavaScript, but any nudge in the right direction.

View 11 Replies View Related

Illustrator Scripting :: Get Keyboard Cursor (caret) Position In JavaScript?

Oct 24, 2013

How can I get keyboard cursor(caret) position in javascript?
 
I made a multilined edittext in ScriptUI.
 
But It's not working about Enter key. 
 
All I want is when I push 'enter' key, begin a new line.
 
If I know how to get keyboard cursor position, I can insert ' ' character in middle of sentances.
 
////////////////////////////////////////////////////////////////////// ///////////////
 var win =new Window ("dialog", '');
win.orientation = "column";
 var grpContents = win.add("group")
var codeInput = grpContents.add ("edittext", [0, 0, 150, 550], "", {multiline:true});
codeInput.alignment = ['fill', 'top']

[code]....
 
I use windowsXP and Illustrator CS3.

View 4 Replies View Related

Illustrator Scripting :: How To Get Position Of Point Text From Left Anchor

Jun 9, 2012

I'm trying to get the position of point text from left anchor if left aligned, middle if center aligned and right if right aligned. is this even possible?
 
here are the keys of object I am trying to get at:
 
keys:
 
story : [Story]
contents : export me
textRange : [TextRange]
textSelection : [TextRange]
rowCount : 1
columnCount : 1
rowGutter : 0
columnGutter : 0
flowLinksHorizontally : true
spacing : 0
opticalAlignment : false
kind : TextType.POINTTEXT
contentVariable : undefined
orientation : TextOrientation.HORIZONTAL
 
this is what I am using to get at it:

app.activeDocument.textFrames[2].anchor[0]
 
am i confusing anchor point with baseline position?

View 3 Replies View Related

Illustrator Scripting :: Change Folder Current To Location Of Script (JSX) File?

Jan 6, 2012

I'm trying to use some images in my ScriptUI dialog, but I want to use a "relative" path name, and I can't seem to get it to work.For example, this myScript.jsx works just fine, but as you can see, I'm using an "absolute" path name to transparencyGrid.jpg:
 
var w = new Window ("dialog");
var f = new File ('~/Desktop/transparencyGrid.jpg');
w.add ("image", undefined, f);
w.show ();
 
However, I want to be able to use a relative (to myScript.jsx) path to point at transparencyGrid.jpg, like this:
 
var w = new Window ("dialog");
var f = new File ('../../../transparencyGrid.jpg');
w.add ("image", undefined, f);
w.show ();
 
But, I can't seem to get this to work because relative paths seem to be relative to the current folder, Folder.current, not the location of the currently executing script.I say that because when I do this:
 
alert(Folder.current);
 
The only thing the alert message shows is a backslash (/), indicating to me that the current folder is the root of my OS, but I thought it would be the folder where myScript.jsx resides.
 
So, is there a way of setting Folder.current to the location of the actual script?

View 2 Replies View Related

Illustrator Scripting :: JavaScript To Send Selected TextFrame To Current Layer?

Feb 20, 2013

Is there a way to send a selected textFrame item to a layer using javascript?
 
I don't mind if it is send to current layer or some other way to accomplish the task.
 
(Using Adobe Illustrator CS4)

View 5 Replies View Related

AutoCAD Visual LISP / AutoLISP :: Move Objects To New Layer Based On Their Present Layer

Jun 20, 2012

Say I have 2 items, one is on layer "M-Duct" and the other on "M-Pipe" (they are in the same drawing). Any lisp routine that would create the layers "M-Duct-New" and "M-Pipe-New" (based on the same color and LT as the original layers) and then move those objects to the newly created layers?

View 9 Replies View Related

AutoCAD Civil 3D :: Create Dynamic EOP Profile Based On Cross Slope From Center Line Profile

Jun 28, 2012

The intersection wizard makes dynamic EOP profiles based off of the cross slope from the centerline.  Well the intersection tool doesn't always work with funky intersection layouts.  Is it possible to manually create a dynamic EOP profile based on the cross slope from the centerline profile?

Civil 3D 2012
Windows 7, 64 bit

View 1 Replies View Related

Illustrator Scripting :: Center Group On Artboard Using JavaScript?

Aug 14, 2013

I have a group that I want centered on the artboard. 

View 9 Replies View Related

Illustrator :: Copy And Paste Position And Size Of Two Different Objects?

Sep 20, 2012

I have a question, quite a tricky one. Is there any way how can I copy and paste position and size of two objects?
 
Let's say I have a circle 2 x 2 cm and it's position is y 5cm x 5cm, I have a square of size 3 x 7 cm and it's position is y 0cm x 0cm.
 
How do I copy and paste in a single command/step the circles position and size to square, so I can get square of 2 x 2 cm and it's position 5cm x 5cm?
 
Something like copy + paste in place with a different logics. I hope You understand what I want.
 
I'm doing it now manually, I'm copying size and position of one object to another [ctrl + c > ctrl + v] but it takes quiet a while,

View 3 Replies View Related

Illustrator :: How To Move The Center Of The Gradient

Jun 25, 2012

I am rebuilding a raster logo in Illustrator and I'm having trouble getting my Gradient how I'd like it.
 
I have a radial gradient applied to an object, but I cannot figure out how to move the center of the gradient.
  
The gradient's center is aligned to the object's center. Can I move the gradient's origin, or possibly the objects center? I attached a screenshot for referance.
 
If I cannot adjust any obj/gradient centers, can I just create my gradient in PS and create a Clipping Mask?  

View 2 Replies View Related

Illustrator Scripting :: Move Layers To New Artboard

Feb 18, 2013

I'm trying to create a script via javascript for Illustrator.
 
My problem is : I have a AI file with multiple layers, i want to create one artboard per layer, in order to export a multipage PDF ( each page contain 1 layer ).
 
The layers represents the differents type of print ( vernish, color, hot gold, pressure ... ) and/or color type ( Pantone, CMYK, cut, kisscut ... ). My client want a PDF for see each type of print or color type per page.
 
I'm trying 2 ways :
 
1st solution : Create new artboards, and duplicate ( or move ) layers content on the new artboad, but the function move/duplicate don't work to move content on another artboard.
 
2nd solution : Create new document with the same number of layers as artboard and duplicate layer to the new artboard on the new document.

View 6 Replies View Related

Illustrator Scripting :: Move PageItems From One Layer To Another?

Dec 19, 2012

I am working on a script to standardize layers and I need to move all the pageItems from a layer called "PART_NUMBER" to a layer named "STATIC".
 
following code at the arrow...
 
I am using "test" to troubleshoot the move.
 
standardizeLayerNames() // This function verifies that the Layer names conform to the standard Layer names.
function standardizeLayerNames()      {  
var myDoc7=app.activeDocument  
var myLayerCount7 = myDoc7.layers.length

[Code] ........

View 4 Replies View Related

Illustrator :: Shade Of Objects Changes Depending On Their Vertical Position On Artboard

Jan 9, 2014

This is  a recent phenomonom, the shade of objects changes depending on their vertical position on the artboard. If I move an object from the top of the artboard to the bottom it becomes lighter, and these changes remain even after it is saved as a png- this is driving me crazy!!! it is very slight, but still enough to cause a headache. If you look at this image you can see that the top blue box is slightly darker than the blue box at the bottom, event though this is the exact same box copied and pasted down the artboard.

View 3 Replies View Related

Illustrator :: Move Center Of Radial Gradient?

Nov 29, 2005

I've got a circle with a radial gradient going from purple on the outside to white at the center (a grape). How do I get the white center to move someplace other than the center? It was easy in Freehand...

View 8 Replies View Related

Illustrator :: Move Center Point Of Object?

Aug 29, 2013

How can I move the center point of an object?

View 2 Replies View Related

Illustrator Scripting :: Move Anchor On Path Item

Jun 21, 2013

All I am trying to do is move an anchor from one location to another using vbscript.  I have searched everywhere and scoured the scripting references but I have not been able to figure this out as of yet.
 
I am able to select anchor points without an issue....moving those points seems to be a problem. 

View 5 Replies View Related

Illustrator Scripting :: How To Move / Translate / Reposition The Group

Jul 10, 2013

I have a document with a single layer and a single group (GroupItem) in that layer.

Unfortunately, I didn't create the .ai file, so I don't know exactly what is in the group; however, there appears to be a bunch of complex clipping masks and gradient effects, etc. deeply nested within it.

I've successfully scripted a few tasks like resizing the group with no ill effect... in other words, this works as expected:
 
app.activeDocument.activeLayer.pathItems[0].resize(50,50);
 
However, as soon as I try to move/translate/reposition the group, all the effects/masks seem to go wonky, I've tried all of the below with no success (200 is just arbitrary as a test):
 
app.activeDocument.activeLayer.pathItems[0].left = 200;
app.activeDocument.activeLayer.pathItems[0].translate(200,0);
 
I have no problem moving the group around on the document with my mouse... all the effects/masks are still nice and clean, so I'm confused as to why I can't do the same thing via JavaScript.

View 3 Replies View Related

Illustrator Scripting :: Copy / Move And Paste Into Different Layer

Nov 12, 2013

I have a script that measures the repeat interval and gap between print impressions printed using a print cylinder (for the production team to know which print cylinders to use, and what to expect once it prints, when looking at the proof sheet). Basically it just measures the distance from the beginning of one print impression to the beginning of the next (these are printed with a cylinder, so every time the cylinder rotates a new print impression happens) as well as the distance in between prints. That part works great.
 
In order to get these meaurements, Illustrator is measuring the distance from a zero point on the artboard to the left side of a marker I made called "repeat", and it is assigned a variable called rawRepeat. What I'd like to do is have the script take that rawRepeat value and use it to move a copy of the print impression to the right by exactly that variable amount and paste it beneath the marker called "repeat". I have been doing this part manually, but haven't been able to figure out how to get illustrator to do this for me.
 
Here's the script I am using:
 
var myDocument = app.activeDocument;
var selectedObject = myDocument.selection;
var activeLayer = app.activeDocument.activeLayer;
var layerName = activeLayer.name;
activeLayer.name = "plate";
 
[Code] ..... 

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved