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

Tags: InDesign

Similar Questions

  • What does that say "automation server can't create the object" with undefined is null or not an object

    I get these pop ups on an application I have to access it through a company VPN

    Hello charliedoodle,

    Given that the application tries to reach a Web site through the VPN to your business, you should check with your integrated personnel.
    They may have a problem on the server, or may have set a new strategy group. We would not be able to help with this issue.

    However, you can watch the following article which addresses the error message you receive.
    Click the number of the KB article to revise article.
    KB Article ID: 323885 -error message in Visual Studio: "Automation server cannot create the object.

    I hope this helps.

    Sincerely,

    Marilyn
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • Creating an index with a script and style

    Hi all

    Using ID CS 4 on Win Vista

    I want to create an index for my book on vegetable oils. Each plant can have many synonyms and common names. The words I want to index will be marked in the screenshot below and follow the Red numbered headings:

    • Plant species
    • Synonyms of plant species
    • Other common names

    The words are separated by commas, and the only things that I don't want under these headings are the abbreviations in brackets

    Here are the codes of language (SP) to Spanish (FR) French etc. I could probably go back and using find/replace and strip this particular style of these entries to exclude from the process if necessary.

    I assigned a style called "Style indexing" at these words I want to be included.

    Is there a script or could a being invented that will MARK these words as index entries?

    I know that Jongware could probably spit in his sleep. Or of the Peters

    I know exactly zilch on the scripts.

    Oil book screenshot.jpg

    Thanks again wonderful guys

    Peter has a few clever tricks here.

    http://www.kahrel.plus.com/InDesign/lists_indexes.html

    P.

  • Creating a tunnel with LV scripts programmatically

    Hello world!

    I'm really stupid question, but lost 3 hours trying to solve it...

    So far, I went through the tutorials on VI scripts available on the Web site of NOR.

    Currently, I am trying to build this VI programmatically:

    I had no problem to create the controls, the add function, the selector of business wire etc. My problem is with the tunnels: how to create them?

    I don't have no idea on what to give to the node 'style' of the 'New VI object' VI. The enum constant has too many a choice to try all the...

    In addition, none of the official example uses a tunnel on a structure (in particular the example 'Working with Structure.lvproj' which is really poor IMO :/))

    OK, I know that there is no official support for the scripts of VI, but I thank you in advance for answering my question!

    Bat.

    The tunnels are very easy or very difficult, depending on how you are what the end result looks like.

    Easy way

    Wire between the two terminals using wire to connectTerminal method.  The tunnel connects automatically for you.

    I want where I want!

    To put the tunnel where you want, you must make sure that the wire goes where you want that he (moving later, the tunnel is much harder).  Thus, for each location where you want a metal elbow, drop something off with a terminal (for example a bundler).  Make sure that the center of the terminal you will thread is where you want your elbow.  Wire between all terminals on all objects, and then delete the temporary objects.  The internal engine of codegen LabVIEW for this.

    Let us know if you need more information.

  • Create an object with a custom code

    Hello

    OK, I'm not sure I'm clear in my title, but I'll try to explain my problem.

    Recently, I request the creation of unlimited QML object. In my example, I want to create a header and an indicator of progress with property ask the user. After that, a timer add '+ 1' for the first indicator of progress, and when its finish, the timer add "+ 1" to the second, etc... ".

    To do this, I want to create an ID for each indicator of progress (PI_1, PI-2, PI_3, etc...).

    How can I do? Can I use the name of the object for that?

    Thanks for your response

    Did you look at my dynamic control KB article?

    It shows you how to set up a connection using signals and slots, that when you work with several items that need work asynchronously is the way to go...

    http://supportforums.BlackBerry.com/T5/native-development-knowledge/how-to-pass-data-to-and-from-a-Q...

    Doing it this way means that the underlying signal/slot mechanism manages the problem "that pits" and you will not need a massive switch statement.
    It has another advantage, as in if you want to stop all the food at once, you can attach a signal to several 'Cancel' slot machines.

  • Select all objects with the same style of object?

    I did some research but empty is come. It is possible to select all the objects on a page that have the same style of applied object?

    What I want to do, is apply an action 'frame content' to a large group of text boxes (labels on a map). But this mounting option doesn't seem to be available as part of the style of the object.

    Any suggestions?

    Thank you.

    Try using the option Auto-size text block rather in the style of the object. This feature (found in the object > text frame Options) is useful to the legends of autosize following certain rules.

    This attribute can be used in object styles.

  • Create the Partition with Maxl

    Hi all

    I tried to create a partitioning with Maxl script and in the process, Essbase is down. I have connected at the back and try to create a partition, then it gives me error saying that there is no such thing as the database object name.

    I don't see any partition of the EAS database, but when I run the command maxl to display the object of type on the database partition, then it gives an entry.

    I tried to drop it by the drop command, but it does not work.

    Can someone enlighten us how to remove the object?

    Concerning

    Celvin

    Presumably, some partitioning temporary files are created under the database folder.

    Just enter in the database folder and remove the following files in the background if persists.

    DDB - partitioning definition file

    DDM - Temporary file partitioning

    DDN - Temporary file partitioning

    Concerning
    NCEA

  • How to create the object rectangular box with a pure action script.

    How to create the object rectangular box with a pure action script?

    I think, it can be done through the clip library, but I'm not sure. Please, I want to take the suggestion to create a rectangular box as a script through

    Take a new file and write about the first image the code below, it works fine:

    var rect = new Shape();
    rect.graphics.beginFill (0xFF0000);
    rect.graphics.drawRect (0, 0, 100,50);
    rect.graphics.endFill ();

    var MC = new MovieClip();
    mc.addChild (rect);
    addChild (mc);

    If this doesn't solve your problem then paste the error you get

  • 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.

  • 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.

  • What script to create a model with a user interface panel

    Hello guys,.

    So I am new to scripting and javascript and I'm trying to keep it simple. I'm a VJ and want to create a script where I get a 'BPM' and a 'beat' lengh and it generate me a comp with the right length and * a layer with a marker ofr each beat.

    I was able to create this script, but I try to make it look a little better with integration of the user interface for AE I wasn't able to make it work right. If anyone can help me or give me some advice. I think that I'm not good with the expression "addComp" in the buildUI function.

    I copy everythin because it is long but you'll be understaind the main idea. My question is how to that the entry in my Advanced UI instead of "the guest".

    Here is my first code that does the job:

    Elements Var Set

    var name = prompt ("membership name");

    var BPM = prompt ("your BPM");

    If (isNaN (BPM)) {}

    Alert ("you must give the model a value");

    }

    Var prompt = beats ("how many times");

    If (isNaN (Beats)) {}

    Alert ("you must give the model a value");

    }

    frameRate var = prompt ("your fps");

    If (isNaN (frameRate)) {}

    Alert ("you must give the model a value");

    }

    term var = (60 / BPM * bat); Automatically generated

    var beat = (60 / BPM);

    Part of creation

    app.project.items.addComp (name, 1920, 1080, 1, duration, frameRate); Create the model with custom Lengh

    App.Project.Item (01).layers.addSolid ([0,0,0], "BG", 1920, 1080, 1, length); Create solid BG

    var firstLayer = app.project.item (1) .layer (1);

    firstLayer.label = 16;

    App.Project.Item (01).layers.addSolid ([0,0,0], "FX", 1920, 1080, 1, length); Create sound FX

    App.Project.Item (01).layers.addNull (Duration); Create the Null object

    var firstLayer = app.project.item (1) .layer (1); Rename the Null object

    firstLayer.enabled = false;

    firstLayer.name = "Beats";

    firstLayer.label = 0;

    Place a marker on the 64 first beat

    var myMarker = new MarkerValue("0");

    firstLayer.property("Marker").setValueAtTime (beat * 0, myMarker);

    Every beat on opacity-keys

    myProperty = firstLayer.opacity;

    myProperty.setValueAtTime (beat * 0, 0);


    For reference, I'm going to place code Dan here and use line numbers, as I explained.

    Fig. A

    var name = prompt("Composition name");
    var BPM =prompt("Your BPM");
    if (isNaN(BPM)) {
        alert("You must give the comp a value");
      }
    
    var Beats = prompt("How Many Beat");
    if (isNaN(Beats)) {
        alert("You must give the comp a value");
        }
    
    var frameRate = prompt("Your fps");
    if (isNaN(frameRate)) {
        alert("You must give the comp a value");
        }
    
    var duration = ( 60  / BPM * Beats ); //Auto Generated
    var beat = (60  / BPM);
    //Creation Part
    var myComp = app.project.items.addComp(name, 1920, 1080, 1, duration, frameRate); // Create Comp with Custom Lengh
    var firstLayer = myComp.layers.addSolid([0,0,0], "BG", 1920, 1080, 1, duration); // Create BG Solid
    firstLayer.label = 16;
    myComp.layers.addSolid([0,0,0], "FX", 1920, 1080, 1, duration); // Create FX Solid
    firstLayer = myComp.layers.addNull(duration); // Create Null Object
    firstLayer.enabled = false;
    firstLayer.name = "Beats";
    firstLayer.label = 0;
    // Place a marker on the 64 first beat
    var myMarker = new MarkerValue("0");
    firstLayer.property("Marker").setValueAtTime(beat*0, myMarker);
    // Key every Beat on opacity
    var myProperty = firstLayer.opacity;
    myProperty.setValueAtTime(beat*0, 0);
    

    OK, so for your configuration, looks like you're striking four data sets. You have the model name (fig.) At line 1), BPM (lines 2-5 of Fig. (A), (lines 7-10 of Fig. rhythms (A) and the FPS (lines 12 to 15 of Fig. (A). then it comes to the UI, you can change what I had posted to...

    res = "group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
      myCompName: EditText{text:'Enter comp name'},\
      myBPM: EditText{text:'Enter BPM'},\
      myBeats: EditText{text:'Enter beats'},\
      myFPS: DropDownList{properties:{items:['23.976', '24', '29.97', '30', '59.97', '60']}},\
      createComp: Button{text:'Create comp'},\
    }"
    

    This will give you all entries in four data for the user interface. It is preferable to assign each control to a new variable for use in your script.

    // Control Variables
      var compName = myPanel.grp.myCompName;
      var myBPM = myPanel.grp.myBPM;
      var myBeats = myPanel.grp.myBeats;
      var fps = myPanel.grp.myFPS;
      var createComp = myPanel.grp.createComp;
    

    Once you have these variables you can then start the default implementation as appropriate. in this case, the drop-down list should be a starting point for it's selection, so that you can say to use the first default entry as follows.

    //Defaults
      fps.selection = 0;
    

    Now, you can configure your onClick for button createComp feature. This will contain to working part of the Dan code that treats everything (lines 17-33 of Fig. (A). I've added a few lines of options above this (lines B Fig. 1-7) in the below code just to match the variable names so you wouldn't need to change the code.

    Fig. B

    //onClick setups
      createComp.onClick = function(){
      //Gather user entered values
      var name = compName.text;
      var BPM = Number(myBPM.text);
      var Beats = Number(myBeats.text);
      var frameRate = fps.selection.text;
    
      var duration = ( 60  / BPM * Beats );
      var beat = (60  / BPM);
      //Creation Part
      var myComp = app.project.items.addComp(name, 1920, 1080, 1, duration, frameRate);
      var firstLayer = myComp.layers.addSolid([0,0,0], "BG", 1920, 1080, 1, duration);
      firstLayer.label = 16;
      myComp.layers.addSolid([0,0,0], "FX", 1920, 1080, 1, duration);
      firstLayer = myComp.layers.addNull(duration);
      firstLayer.enabled = false;
      firstLayer.name = "Beats";
      firstLayer.label = 0;
      // Place a marker on the 64 first beat
      var myMarker = new MarkerValue("0");
      firstLayer.property("Marker").setValueAtTime(beat*0, myMarker);
      // Key every Beat on opacity
      var myProperty = firstLayer.opacity;
      myProperty.setValueAtTime(beat*0, 0);
      }
    

    Then line 2 Fig. b starts the call onClick for button and assigns a function. Within the function, we run the process. Fig. B Line 4 seizes the compName edit text attribute of the text control, using the Number() function convert us this text to a number for use online B Fig. 9 and 10 and B Fig. 5 line gets the text attribute of the text control edit BPM. Goes same for line 6 of the Fig. B and the beats variable. For line B Fig. 7, a drop-down list requires calling his selection of the attribute, then it is text attribute to get the actual string. The drop was more logical for FPS due to the standard rates that exist. This list can be changed of course to your liking. Now, there is no safety net as I like to call for the modification of the text controls to make sure text is not entered when you need a number and vice versa. It would be something of can check after line 7, Fig. B before trying to run the code in process (Fig. B lines 9-25). I hope that it will be easy enough for you to understand.

    If the script is as follows.

    {
    function myScript(thisObj) {
      function myScript_buildUI(thisObj) {
      var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "My Panel Name", [0, 0, 300, 300]);
    
      res="group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
      myCompName: EditText{text:'Enter comp name'},\
      myBPM: EditText{text:'Enter BPM'},\
      myBeats: EditText{text:'Enter beats'},\
      myFPS: DropDownList{properties:{items:['23.976', '24', '29.97', '30', '59.97', '60']}},\
      createComp: Button{text:'Create comp'},\
      }"
    
      //Add resource string to panel
      myPanel.grp = myPanel.add(res);
    
      // Control Variables
      var compName = myPanel.grp.myCompName;
      var myBPM = myPanel.grp.myBPM;
      var myBeats = myPanel.grp.myBeats;
      var fps = myPanel.grp.myFPS;
      var createComp = myPanel.grp.createComp;
    
      //Defaults
      fps.selection = 0;
    
      //onClick setups
      createComp.onClick = function(){
      //Gather user entered values
      var name = compName.text;
      var BPM = Number(myBPM.text);
      var Beats = Number(myBeats.text);
      var frameRate = fps.selection.text;
    
      var duration = ( 60  / BPM * Beats );
      var beat = (60  / BPM);
    
      //Creation Part
      var myComp = app.project.items.addComp(name, 1920, 1080, 1, duration, frameRate);
      var firstLayer = myComp.layers.addSolid([0,0,0], "BG", 1920, 1080, 1, duration);
      firstLayer.label = 16;
      myComp.layers.addSolid([0,0,0], "FX", 1920, 1080, 1, duration);
      firstLayer = myComp.layers.addNull(duration);
      firstLayer.enabled = false;
      firstLayer.name = "Beats";
      firstLayer.label = 0;
    
      // Place a marker on the 64 first beat
      var myMarker = new MarkerValue("0");
      firstLayer.property("Marker").setValueAtTime(beat*0, myMarker);
      // Key every Beat on opacity
      var myProperty = firstLayer.opacity;
      myProperty.setValueAtTime(beat*0, 0);
      }
    
      //Setup panel sizing and make panel resizable
      myPanel.layout.layout(true);
      myPanel.grp.minimumSize = myPanel.grp.size;
      myPanel.layout.resize();
      myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}
    
      return myPanel;
      }
    
      var myScriptPal = myScript_buildUI(thisObj);
    
      if ((myScriptPal != null) && (myScriptPal instanceof Window)) {
      myScriptPal.center();
      myScriptPal.show();
      }
      }
    
      myScript(this);
    }
    
  • Duplicate a Style object with implemented paragraph in the shape and layout of Rectangle.

    Hey,.

    I'm trying to reproduce an object style, but I don't know if I've set up correctly.

    I have a rectangle object with features and apply effects fx corners, gradient feather, transparency.
    I also have a text frame where there is a paragraph header and format a drop cap for the main text paragraph format.

    Screen Shot 2015-04-08 at 10.12.32 PM.png

    Screen Shot 2015-04-08 at 10.01.53 PM.pngScreen Shot 2015-04-08 at 10.01.38 PM.png

    Rather than go through this process again, I thought create an object style would save time, but how do I group these two frameworks (framework text and rectangle shape) and apply an object style? I am only allowed to apply an object style individual the text block or rectangle object. It also doesn't help when I try to create a rectangular frame around two previous topics.

    In the paragraph style Panel, you need to change your paragraph style "Header."

    in "next style", you have to choose which style you want to be next.

    You can apply your "object Style 1' and tick 'apply the following Style'

  • I created a form with fields default text for a user to update/customize.  Is there a way to style of the text, so I can quickly identify the changes to the default text in a field?

    I created a form with fields default text for a user to update/customize.  Is there a way to style of the text, so I can quickly identify the changes to the default text in a field?

    You can use a validation script customized to each text field that looks like:

    event.target.textFont = event.value = event.target.defaultValue? font. HelvI: fonts. Helv;

    This will make the text italic (Helvetica) when the field value is the value default and regular otherwise. There are other properties that you can use instead, as the field color, border width, background color, text or text size...

  • Cannot install my printer/error message-unable to create the object print dell v505, that the printer is not compatible with a polcy enabled on your computer that blocks NT 4.0 drivers (1930)

    Original title: cannot install my printer error message

    I am trying to install my printer to dell v505 from the factory disc and get this error message: failed to create the object print dell v505 printer is not compatible with a polcy enabled on your computer that blocks NT 4.0 drivers (1930)

    Any help, need a lot.

    Hello

     
    1. what version of Windows are you using?
    2 did you the chnages in the computer before this problem?
     
    I would suggest trying the following methods and check.
     
    Method 1: Run the fix, install the printer and check
    Diagnose and automatically fix problems printing and printer
    http://support.Microsoft.com/mats/printing_problems/
     
    Method 2:
    Error message when you try to connect to a printer in Windows Vista: "the printer driver is not compatible with a policy enabled on your computer that blocks NT 4.0 drivers.
    http://support.Microsoft.com/kb/931719
    Method 3: Install the printer in a clean boot state.
    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7.
    http://support.Microsoft.com/kb/929135
    Note: Please, go to step 7 of the Kb to maintain the computer to normal startup.
     
    You can download the latest driver for your printer from the link below.
    http://www.Dell.com/support/drivers/us/en/04
     
     
    You can also check:
    Printer driver is not Compatible if a policy is enabled on your computer.
    http://support.Microsoft.com/kb/282011
     
    Error message when you try to connect to a printer in Windows Vista: "the printer driver is not compatible with a policy enabled on your computer that blocks NT 4.0 drivers.
    http://support.Microsoft.com/kb/931719
  • "Failed to create the object print Lexmark X 5400 Series. The printer driver is not compatible with a policy on your computer

    I have Lexmark X 5410 printer with the installation CD. Installed perfectly on computer with Windows Vista 32 bit. Try to install on Vista 64 bit computer but get error message "unable to create the object print Lexmark X 5400 Series. The printer driver is not compatible with a policy on your computer that blocks NT 4.0 drivers (1930). Tried using the compatibility in the computer. Without success. How can I fix?

    Original title:

    32-bit and 64-bit Windows: frequently asked questions
    http://Windows.Microsoft.com/en-us/Windows-Vista/32-bit-and-64-bit-Windows-frequently-asked-questions

    Excerpt:
    Can I run a 32-bit program on a 64-bit computer?

    Most programs designed for 32-bit version of Windows works on the version 64-bit windows. The notable exceptions are many antivirus programs.

    Device drivers designed for 32-bit versions of Windows do not work on computers running a 64-bit windows. If you try to install a printer or other device that only has 32-bit drivers available, it won't work correctly on a 64-bit version of Windows. If you don't know if there is a 64-bit driver available for your device, go online to theVista Compatibility Center"" href = "http://go.microsoft.com/fwlink/?linkid=142444" > Windows Vista Compatibility Center

    .
    For the benefits of others looking for answers, please mark as answer suggestion if it solves your problem.

Maybe you are looking for