Skip navigation
thomas.jeorge
Currently Being Moderated

Anchored Object

May 8, 2012 11:08 AM

Hi Scripters,

 

 

I want to place copied object as a anchored object in selection[0]. And need Anchored object custom setting.

 

Please pass the JS code for this.

 

Thanks in advance.

Thomas

 
Replies
  • Currently Being Moderated
    May 9, 2012 5:49 AM   in reply to thomas.jeorge

    This is an example of of a script I made for myself some time back.

    You should be able to figure out from it what you need to do.

    (you should see that many off the lines are not needed )

     

    #target "InDesign"
    app.displayPerformancePreferences.ignoreLocalSettings=0;
    app.displayPerformancePreferences.defaultDisplaySettings = ViewDisplaySettings.highQuality;
    myDoc = app.activeDocument;
    app.scriptPreferences.enableRedraw =0;
    myPage = app.activeWindow.activePage.name;
    userHoriz = app.documents[0].viewPreferences.horizontalMeasurementUnits;
    userVert = app.documents[0].viewPreferences.verticalMeasurementUnits;
     
    app.documents[0].viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
    app.documents[0].viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;
    try {app.doScript("threeRoses()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Three Roses");}
    catch (noObjectStyles) {
        objectStyleSetup ();
        app.doScript("threeRoses()", ScriptLanguage.javascript, undefined, UndoModes.FAST_ENTIRE_SCRIPT, "Three Roses");}
     
    app.documents[0].viewPreferences.horizontalMeasurementUnits = userHoriz;
    app.documents[0].viewPreferences.verticalMeasurementUnits = userVert;
     
    function threeRoses()
    {
    myInsertionPoint=app.selection[0].insertionPoints[0];
    frame = myInsertionPoint.parentTextFrames[0];
    frame.localDisplaySetting = DisplaySettingOptions.HIGH_QUALITY;
        roseFile="C:/InDesign/Pastes/individual flowers.ai";
       roseStyle=myDoc.objectStyles.item("Three Roses");
    myRose= myInsertionPoint.rectangles.add({geometricBounds:[0, 0, 4, 18],  appliedObjectStyle: roseStyle, localDisplaySetting: DisplaySettingOptions.HIGH_QUALITY});
    myRose.contentType=ContentType.GRAPHIC_TYPE;
    //myRose.visible=0;
    myRose.place(roseFile);  
    myRose.localDisplaySetting = DisplaySettingOptions.HIGH_QUALITY;
    }   
     function objectStyleSetup ()
     {
    enabled= {enableTextFrameGeneralOptions:1, enableAnchoredObjectOptions:1, enableStrokeAndCornerOptions:1,enableTextWrapAndOthers:1,enableFrameFittingOptions:1};
    try {
    var threeRoses = myDoc.objectStyles.item("Three Roses");
    // threeRoses.remove();
    var myName = threeRoses.name;
        }
        catch (myError){
            //The object style did not exist, so create it.
            threeRoses = myDoc.objectStyles.add({name:"Three Roses"});
        }
    with (threeRoses) {
    anchoredObjectSettings.anchorPoint = AnchorPoint.TOP_CENTER_ANCHOR;    
    anchoredObjectSettings.horizontalReferencePoint=AnchoredRelativeTo.TEXT_FRAME;    
    anchoredObjectSettings.horizontalAlignment=HorizontalAlignment.CENTER_ALIGN;
    anchoredObjectSettings.verticalAlignment = VerticalAlignment.TOP_ALIGN;
    anchoredObjectSettings.verticalReferencePoint =VerticallyRelativeTo.LINE_BASELINE;
    anchoredObjectSettings.anchorYoffset = 3;
    anchoredObjectSettings.anchoredPosition = AnchorPosition.ANCHORED;
    textWrapPreferences.textWrapMode=TextWrapModes.JUMP_OBJECT_TEXT_WRAP;
    textWrapPreferences.textWrapOffset=[1,1,1,1];
    frameFittingOptions.autoFit=1;
    frameFittingOptions.fittingOnEmptyFrame=EmptyFrameFittingOptions.CONTENT_TO_FRAME;
    frameFittingOptions.fittingAlignment=AnchorPoint.TOP_RIGHT_ANCHOR;
    strokeWeight=0;
    properties= enabled;
    }
    }
    
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points