Create "Object Style" by script

Hello

My 'Library.indl' file has the "Box1", "Box2". I need to create the object style (with dummy properties) based on library file names.

If the library has BOX1, BOX2, I need to check my Indesign file has a Style of object with the same name (BOX1, BOX2).

If an object style is not presented in this particular name (BOX1, BOX2) in Indesign, I create the dummy object style. (The "style object name must match with BOX1, BOX2).

Is it possible by Indesign script?

by

hasvi

Hi Hasi,

Use the code below.

var doc = app.activeDocument;

Library of var = new File ("C:/Library.indl"); Library /Your. file path

App.Open (Library);

assets = app.libraries [0] .assets;

for (var i = 0; i)<>

{

try {}

doc.objectStyles.add({name:asset[i].name});)

}

{catch (e)}

}

Kind regards

Cognet

Tags: InDesign

Similar Questions

  • Creating an object with a script style

    I slowly teach me scripting, but my first script has a bug that I can't fix. Part of it creates an object called a "plain text" style that has certain qualities. One of these attributes is that the first offset base should be "attached" to a certain leader. When I run the script in InDesign CS3, sometimes it works and the first base offset is "fixed", but sometimes this does not work and the first base line offset remains at the default of "rise." I need to work in InDesign CS4, too, but it does not there at all. I looked into the DOM, but it seems that everything is coded correctly.

    Here is a part of the script. What Miss me?

    Create the object style "plain text".
    var myPlainTextObjectStyle = myDocument.objectStyles.add ();
    {with (myPlainTextObjectStyle)}
    name = "plain text";
    enableFill = true;
    enableStroke = true;
    enableStrokeAndCornerOptions = false;
    enableTextFrameBaselineOptions = true;
    enableTextFrameGeneralOptions = true;
    fillColor = myDocument.swatches.item (0);
    strokeColor = myDocument.swatches.item (0);
    textFramePreferences.firstBaselineOffset.firstBaseline = FirstBaseline.FIXED_HEIGHT;
    textFramePreferences.minimumFirstBaselineOffset = myLeading;
    textFramePreferences.textColumnCount = 1;
    textFramePreferences.verticalJustification = VerticalJustification.TOP_ALIGN;
    }

    Your problem is that you have an extra "firstBasline" in the line that defines the firstBaselineOffset. Your script is:

    //Creating the "plain text" object style.
    var myPlainTextObjectStyle = myDocument.objectStyles.add();
    with(myPlainTextObjectStyle){
    name = "plain text";
    enableFill = true;
    enableStroke = true;
    enableStrokeAndCornerOptions = false;
    enableTextFrameBaselineOptions = true;
    enableTextFrameGeneralOptions = true;
    fillColor = myDocument.swatches.item(0);
    strokeColor = myDocument.swatches.item(0);
    textFramePreferences.firstBaselineOffset = FirstBaseline.FIXED_HEIGHT;
    textFramePreferences.minimumFirstBaselineOffset = myLeading;
    textFramePreferences.textColumnCount = 1;
    textFramePreferences.verticalJustification = VerticalJustification.TOP_ALIGN;
    }
    

    Even if there's a better syntax you can use:

    //Creating the "plain text" object style.
    var myPlainTextObjectStyle = myDocument.objectStyles.add();
    myPlainTextObjectStyle.properties = {
         name : "plain text",
         enableFill : true,
         enableStroke : true,
         enableStrokeAndCornerOptions : false,
         enableTextFrameBaselineOptions : true,
         enableTextFrameGeneralOptions : true,
         fillColor : myDocument.swatches.item(0),
         strokeColor : myDocument.swatches.item(0),
         textFramePreferences : {
              firstBaselineOffset : FirstBaseline.FIXED_HEIGHT,
              minimumFirstBaselineOffset : myLeading,
              textColumnCount : 1,
              verticalJustification : VerticalJustification.TOP_ALIGN
         }
    }
    

    What makes this better, it is just an interaction with the object model, rather than one for each property in the object style.

    Dave

  • Create an object Style that sets out a framework to an exact size?

    I know I can use a style object to insert the contents of the frame, but what to make a frame one size I need using a style object?

    I am trying to automate my workflow a bit more. I work at a small magazine and we have 7 sizes different options for ads. Our quarter page ads are 3.875 x 5, for example, and I would like to create a style for the pages of quarter which is exactly this size and fits the content to the boot image. We try to create all the ads to the size, but sometimes the deadline, we get ads ready camera through to the last possible moment that are only a fraction off so appropriate to the framework is not a problem, but from now on as long as the frame is 3.875 x 5 for a quarter, 8,625 x 11,125 for full page, etc..

    If a customer changes sizes add us a link to the new announcement in the new spot, and adjust each box manually. It becomes tedious to check every ad and correcting sizes and locations one since we have hundreds of ads per magazine and 3 magazines every month. (we will add more than 3 magazines in a year so I need to get this whipped into shape!)

    Finally, I would like to create a script/scripts to automate my workflow more, but my first step is trying to figure out if I can have a specific image applied with a Style of object size.

    If im going to this topic in the wrong, is there a better way to do it?

    If you have CS5 you can configure the States of the object.

    If you set 1 state object to a size to say the big announcement.

    Then object state 2 to the size of the media

    Object state 3 to be size small

    and so on

    You can then select the State of the necessary object for advertising - and import the ad in this way - and each State of the object may have its own frame mounting Options to automatically scale the image to correct the proportion.

    This should work pretty well - even though I don't him have not completely tested.

  • Component ActiveX cannot create object wrong when VB script call a dll

    Hello

    I'm new to VB and .NET. We have a SQL job in our application (developed by someone else) hosted on Win Server 2003, who calls the VB script and this script inturns calls a DLL.

    When I run this job, I get the error - component ActiveX cannot create object.

    I tried to print the source of the error (by Err.Source and it gives me 'Microsoft VBScript runtime error').

    Any help would be appreciated. Let me know if I could extract more information.

    Thanks in advance.
    ME

    Hi SenLady,

    The question you have posted here is related to Visual Basic and would be better suited on MSDN forum. I suggest you post your question on the following link.

    http://social.msdn.Microsoft.com/forums/en-us/categories

  • I created an object style to set the distance of the legend of my photos, but the distance is not consistent from one image to the image.

    I create a complex book with many images and chapters.

    I created the object styles to compensate for the distance the images for legends, but the distance changes according to how the image is adjusted within the framework and I don't know what dictates change. Anyone have any ideas?

    Thank you.

    I have not marked as correct answer because it is not related to what you have actually done, which has been reset to the scale. Your problem seems to come from having defined preference generally by climbing, adjust the percentage.

    Frankly, I think it is a bug.

  • Can I create a form using the object styles in InDesign

    Hello

    Is it possible to create a form in the object Styles I can create in InDesign? I know that I can attribute some qualities, but I would like to create a capsule form that will be repeated throughout a page of lists in our sites.

    So far, I have to copy, paste, and anchor the object in the text which is quite time that we have thousands of ads, and life is too short for mundane tasks.

    If I can create a form of object Styles, by entering its dimensions, it will allow me to create the style for import into InDesign, 4 d, our CMS.

    If not, can we have it in a new construction, please Adobe?

    I look forward to your reply.

    Thank you

    Roy

    That can be done with tabs and styles nested using underscore with a custom stroke style. I hope that these screenshots should explain it...

  • Automatic text using a style object, variable, or script?

    Ce_que I would do, is to have an object style that will assign to a frame 1) dressing, 2) vertical center and 3) put the Page Blank words unless I have to type them in each time. I already have the object style set for the scarf, the alignment and the paragraph to the text style. Is a way - maybe with a script or a variable, or a simpler way - that this could be done automatically? I hope I'm being clear.

    I don't know if it's important for this question, but I use InDesign CC (later) on a Windows 7 desktop PC.

    Thank you very much.

    What happened just apply a master page to all the empty pages (looks like that's what you're talking about)? On the master page includes an image with the text you want.

  • Create 'Table cell Style' by script

    Hello

    I want to check the style of table cell was created in indesign? If not created I need to create the style name of cell with dummy properties such as 'TBL_COLH', 'TBL_BODY' (is the cell style name).

    1. If the 'TBL_COLH' & 'TBL_BODY', this cell style appeared in Indesign, give me alert ' the cell style, already present in Indesign.

    2. If the 'TBL_COLH' & 'TBL_BODY' this cell style not appeared in Indesign, I need to create the cell with dummy properties style.

    Is it possible by script?

    by

    Hasvi

    Hi Hasvi,

    Yes, possible. It's here.

    var doc = app.activeDocument;

    var table = ['TBL_COLH', 'TBL_BODY'];

    for (var i = 0; i)<>

    {

    try {}

    doc.cellStyles.add({name:array[i]});)

    }

    catch (e)

    {

    Alert ("'" + array [i] + "'" + "already exists in the document.")

    }

    }

    Kind regards

    Cognet

  • Find the element of object styles, and then copy it

    Hello, I would like to create a script.

    Find elements of object styles:

    Outside of the document, I create on block with the style of the object "reference". It will be unique.

    Once selected, I want to put it on the Clipboard or simply make a copy.

    If selected by object styles is not possible, how can I do an id on my element?

    Can you help me?

    Thancks a lot!

    YES!

    I solved the problem like this:

    var obj1 = app.selection [1];

    var obj2 = app.selection [0];

    Alert (obj1 and obj2);

    obj1. Select();

    App.Copy ();

    app.loadFindChangeQuery ("PuceSimple_enPuceCouleur_Courant", SearchModes.grepSearch);

    obj2.changeGrep ();

    But I have a question.

    How the script knows which is the number 0 and the number 1?

    This is the order of selection? in position on the page?

    Could be done as follows:

    var obj1 is app. Docuement.Item ("reference");

    var obj2 = app.selection [0];

  • Object styles palette empty after computer crash. CS6

    Last week I had a power outage and my computer crashed. Since the objects in indesign CS6 palette shows nothing, that it is empty, even if the styles are still present in all of my archived documents. This seems to affect all files on my computer, and I am also unable to create new styles in old or new files.

    See: troubleshooting 101: replace, or 'trash' your InDesign preferences

  • best judgment for paragraph styles, object styles and character styles

    I want to learn the criteria difference and use of paragraph styles, object styles and character styles. I know how to use them, but know about the best judgment and context, when you use would be better. Can anyone recommend links? I've been using adobe. Please don't suggest books.

    Paragraph styles are whole paragraphs.

    Character styles are letters or isolated words. Do not use the long of an entire paragraph. Do not set all the attributes, only those who are different for the properties of the paragraph Style. Unlike Quark Xpress, in InDesign are character Styles used only for the difference of isolated words.

    Paragraph styles can include the character automatically Style: Styles, GREP, nested Styles, initial letters, chips automatic & numbers and line styles.

    Object styles , set the frame of the object. They include separate definitions of all of the object, the stroke and fill.

    Object styles can also be applied to images in a frame and groups.

    Object styles may also include in the following paragraph Style and a style of paragraphs in automatic way.

    Object styles have several categories, you can choose which category is relevant to apply. For example, it is possible to apply the first style object to give the stroke and fill and apply a different object style to format the corners only and then apply the next. (With this method last only the applied object Style is linked).

    Styles of the opportunity to make global changes in a document. If you build in a smart way, they are a huge time saver. They can be stored in the CC libraries or libraries with objects that are applied to them. If you have created once these styles, you can use them again, and with one or two clicks, you can make their own to new document.

    My recommendation: the habit of Styles, name them always with the same names that it helps you to be accustomed to them and to work faster, much faster.

    There are more models: Table Styles, Styles of cell, the Master Pages and color chart.

  • can't save a style I create heading styles

    I can't understand how to save a style I create in the section "title".

    1. My steps are that I have create a title on my calendar with Ctrl-T
    2. Appears in the window title
    3. I click on a heading style similar to what I want
    4. I have change the style in the properties I want (that works)

    From there, how to update the style so the next time I use this style of title, I get the same settings?  I can't understand how to create a new style that is not just the default values.

    Create a style

    • Select an object that has the properties you want to save it as a style.
    • Do one of the following:

      • In the title Styles Panel menu, choose New Style.
      • Click the right button (Windows) or Ctrl-click (Mac OS) in the Panel Heading Styles, and then choose New Style.
    • Type a name for the style, and then click OK. Depending on the display option selected, either a sample displays the new style or the new style name appears in the title Styles Panel.
    from there:
  • Object styles cannot be deleted

    I use 8 Captivate and there is some object styles I want to remove the file that I can't. Does anyone know a workaround for this?

    3333.png

    These styles with brackets around them are default object styles.  You will not be able to remove them.  It seems that the project has been created using a German version of Captivate?  Is this likely?

  • The bubbles... using object styles

    Hi all! I took over a project in InDesign that was created by another designer. It's something I can't understand. There is a graph. And behind the text of the "bubbles". These are created using the object styles. The sentence I feel, is that when I merge the bubbles, mine out differently to what they were doing. And I can't for the life of figure me out how to do what they were doing. Any suggestions would be greatly appreciated.

    Basically, it's the 'corners' which are the cause. When I merge the two bubbles, there is a small dip. But when they merged their, it comes out instead of in. See what I mean below. I can't quite explain it with words.bubbles copy.jpg

    In my suggestion rounded corner effect = Option of round corner. My point is: the order in which you merge forms and apply rounded corners will have different results.

  • Apply an object style to the group without changing the object style of page within the group elements?

    Does anyone know a way to apply an object style to a group without changing the style of the subject of the articles within the Group?

    Well, as far as I know, there no way to do it. Apply an object style to a group applies this style to all elements within the group as well. So, I resorted to writing a script for this.

Maybe you are looking for