• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Search document for SpecialCharacters Enumerator

People's Champ ,
Jan 19, 2012 Jan 19, 2012

Copy link to clipboard

Copied

Hi,

I've placed a Word document that has loads of irritating Unicode markers

(left-to-right etc.)

There is no way that I can see of using the UI to search and delete

these characters.

The unicode value of these markers is: 0x200E as it appears from the

Info palette, but that Unicode value is shared by various things.

Selecting a marker and get its contents (app.selection[0].contents)

returns the number: 1399616109. This is in fact the number for

SpecialCharacters.LEFT_TO_RIGHT_MARK.

To cut a long story short and make a specific question general:

How do you search for a SpecialCharacter that doesn't have an escape

code in the GREP find/replace?

What I've done so far is looped through all the characters in the

document and compared their contents to 1399616109. But this is very

slow, and is also causing InDesign to crash.

Is there a better way?

Thanks,

Ariel

TOPICS
Scripting

Views

5.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jan 19, 2012 Jan 19, 2012

Copy link to clipboard

Copied

Hi Ariel,

Use the Unicode code point in the GREP F/R field this way:

\x{200E}

See also:

http://www.indiscripts.com/post/2009/07/idcs4-special-characters

@+

Marc

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jan 19, 2012 Jan 19, 2012

Copy link to clipboard

Copied

Hi Marc,

Thank you. I couldn't find that documented anywhere.

Ariel

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jan 19, 2012 Jan 19, 2012

Copy link to clipboard

Copied

To complete my previous post:

1) Given a Character myChar whose contents property returns a SpecialCharacter enumerator, you can still retrieve the Unicode codepoint using myChar.texts[0].contents instead of myChar.contents:

alert( myChar.texts[0].contents.charCodeAt(0).toString(16) ); // => Unicode CP (hexa)

2) Since ID CS5 the Enumeration objects (Locale, SpecialCharacters, etc.) describe a set of Enumerator objects rather than a set of numbers. An Enumerator is a special native object which converts itself into either a String or a Number depending on the context:

// ID CS5+

alert( SpecialCharacters.emDash ); // => EM_DASH (string)

alert( +SpecialCharacters.emDash ); // => 1397058884 (number)

In fact, these respectively correspond to myEnumerator.toString() and myEnumerator.valueOf():

// ID CS5+

var myEnumerator = SpecialCharacters.emDash;

alert( myEnumerator.toString() ); // => EM_DASH (string)

alert( myEnumerator.valueOf() ); // => 1397058884 (number)

But every Enumerator has its == and === operators overriden so as we can still compare it with a number:

alert( SpecialCharacters.emDash==1397058884 ); // => true

alert( SpecialCharacters.emDash===1397058884 ); // => true

Also, an Enumeration object see both the camelcase and the uppercase name of an enumerator as a regular own property:

// ID CS5+

alert( SpecialCharacters.hasOwnProperty('emDash') ); // => true

alert( SpecialCharacters.hasOwnProperty('EM_DASH') ); // => true

Both are [[enumerable]] but the for-in loop only collects the uppercase forms ('EM_DASH', etc.).

@+

Marc

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jul 08, 2012 Jul 08, 2012

Copy link to clipboard

Copied

Hi Marc or anybody else who knows

Is there a way of getting the full Enumeration string, i.e. SpecialCharacters.EM_DASH and not just EM_DASH ?

Regards

Trevor

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 08, 2012 Jul 08, 2012

Copy link to clipboard

Copied

Huh?

I'm not sure what you are asking...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jul 08, 2012 Jul 08, 2012

Copy link to clipboard

Copied

Hi Harbs

If I want to get the Enumeration value for an object I could use for example.

app.selection[0].appliedParagraphStyle .diacriticPosition*1

I would get back the value for example 1685090164

To get the string of the enumaration I can use

app.selection[0].appliedParagraphStyle .diacriticPosition.toString()

this will return OPENTYPE_POSITION (will also return this without the toString but the toString prevents it revering back to a numeric)

If I were to enter app.selection[0].appliedParagraphStyle .diacriticPosition = 1685090164 that's going to work

but if I enter app.selection[0].appliedParagraphStyle .diacriticPosition = OPENTYPE_POSITION that's not going to work.

In this non-numeric form I need to enter app.selection[0].appliedParagraphStyle .diacriticPosition = DiacriticPositionOptions.OPENTYPE_POSITION

Is there a way of "Extracting" this term DiacriticPositionOptions ?

I hope that's clear (have my doubts) if still not clear I have a script that I can post that should make it clear.

Trevor

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jul 08, 2012 Jul 08, 2012

Copy link to clipboard

Copied

I think it might be useful to include this script.

I preduces a "manual" of how to set the properties of a selected object (between 40 to 100 pages of properties).

The script is not finished but works quite nicely.

Select an object / text / something and then run the script. Takes about 30 seconds to run.

If I say so myself it's quite a nice not script

Let me know if all clear.

#target "indesign"

#targetengine "main"

myDoc = app.activeDocument;

mySelection=app.selection[0]

pl=""

    myProperties=mySelection;

    myPropertiesString="app.selection[0]";

//mo = new Object

//mo = {a:4, b:5, c:{q:5, w:8, ss:"foo", fred:{we:5,fh:65}}, d:10};

s=""

ss=0;

myObjConstructor=myProperties.constructor.name.toString();

n = (myObjConstructor[0]=="A" ||myObjConstructor[0]=="E" ||myObjConstructor[0]=="I" ||myObjConstructor[0]=="O" ||myObjConstructor[0]=="U") ?

"n ": " ";

s="* "+myPropertiesString+" is a"+n+myObjConstructor+" *\r\r";

elem(myProperties,myPropertiesString)

function elem(obj, subObj)

{

var oldSubObj = subObj;   

var p=0

var y=[]

var z = []

for (x in obj)

{ ++p

    y

=x

ss++;

try { (obj!=null) ? z

=obj : z

="nullnulllnull";} catch (notApplicable) {z

="null"}

try {zz= z

.properties} catch (np) {zz=z

.constructor.name; /*alert(z

)*/};

zzz=z

.constructor.name;

szp=(zzz=="Enumerator") ? z

.toString() + " or ":"";

if (z

!=null)

    { if     (zz=="[object Object]" )

    {

        if( y

!="parent"&& y

!="parentStory"

        && y

!="startTextFrame"  && y

!="endTextFrame"

        && y

!="nextTextFrame"  && y

!="previousTextFrame"

        && y

!="nextStyle" && y

!="previousStyle"

        && y

!="pageStart" && y

!="pageEnd"

        && y

!="index" && y

!="index") 

    {

        var sz=(subObj+"."+y

.toString())

        s+=subObj+" ."+y

+" = "+z

+"\t"+zz+"\t"+zzz+" *\r";

    

      eval("elem("+sz+",'"+sz+"');");

       

    }}

  else   {s+=subObj+" ."+y

+" = "+szp+z

+"\t"+zz+"\t"+zzz+"\r";subObj = oldSubObj ;}

} else  {s+=subObj+" ."+y

+" = "+szp+z

+"\t"+zz+"\t"+zzz+"\r"; subObj = oldSubObj ;}

 

subObj = oldSubObj ;

}  }

myContents=s;

myDoc = app.documents.add();

app.activeDocument.layoutWindows[0].screenMode = ScreenModeOptions.PRESENTATION_PREVIEW;

oldUnits=app.scriptPreferences.measurementUnit;

app.scriptPreferences.measurementUnit=MeasurementUnits.MILLIMETERS;

myDoc.documentPreferences.properties =

{facingPages:0, intent:DocumentIntentOptions.PRINT_INTENT, pageHeight:210,

   pageWidth:297, pageOrientation:PageOrientation.LANDSCAPE}

setUpStyles();

mastertextFrames = myDoc.masterSpreads.item("A-Master").textFrames.add

({geometricBounds: [200,0,210,297], contents:SpecialCharacters.AUTO_PAGE_NUMBER});

mastertextFrames.parentStory.paragraphs[0].justification=Justification.CENTER_ALIGN

mastertextFrames.duplicate([297,200])

myTextFrame = app.activeWindow.activePage.textFrames.add({geometricBounds:[12, 12, 198, 285], strokeWeight:0, strokeColor:"None"});

myTextFrame.parentStory.appliedParagraphStyle=mps

myTextFrame.parentStory.contents=myContents

while (myTextFrame.overflows) {addPage(myTextFrame)}

function addPage(prevTextFrame)

{

    myPage = myDoc.pages.add();

    myTextFrame = myPage.textFrames.add({geometricBounds:[12, 12, 198, 285], strokeWeight:0, strokeColor:"None"});

    myTextFrame.previousTextFrame = prevTextFrame;

}

function setUpStyles()

{

    mcs=myDoc.characterStyles.add({name:"Value", fillColor:"Black", appliedFont:"Minion Pro", fontStyle:"Bold"});

    mcs2=myDoc.characterStyles.add({name:"Properties", fillColor:"Black", appliedFont:"Minion Pro", fontStyle:"Bold Cond"});

    mcs3=myDoc.characterStyles.add({name:"Property", fillColor:"Black", appliedFont:"Minion Pro", fontStyle:"Bold Italic", horizontalScale:115});

    mcs4=myDoc.characterStyles.add({name:"Object", pointSize:6, underline:1});

   

   

    mps=myDoc.paragraphStyles.add({name:"main", pointSize:3.5, fillColor:"C=0 M=100 Y=0 K=0", appliedFont:"Minion Pro", fontStyle:"Medium", justification:Justification.LEFT_ALIGN,

    paragraphDirection:ParagraphDirectionOptions.LEFT_TO_RIGHT_DIRECTION, digitsType:DigitsTypeOptions.ARABIC_DIGITS})

mps.nestedGrepStyles.add({appliedCharacterStyle:mcs4, grepExpression:".+?\\*$"});

mps.nestedGrepStyles.add({appliedCharacterStyle:mcs, grepExpression:"(?<=\=).+?\\t"});

mps.nestedGrepStyles.add({appliedCharacterStyle:mcs2, grepExpression:"^\\S+"});

mps.nestedGrepStyles.add({appliedCharacterStyle:mcs3, grepExpression:"(?<=\s).+? \="});

   

}   

app.activeWindow.activePage = app.activeDocument.pages[0];

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 08, 2012 Jul 08, 2012

Copy link to clipboard

Copied

You can use Enum.valueOf() to get the numeric value.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jul 08, 2012 Jul 08, 2012

Copy link to clipboard

Copied

But I don't want the numeric value I want the full enumaration string i.e.

DiacriticPositionOptions.OPENTYPE_POSITION as apposed to just OPENTYPE_POSITION

Did you run the script?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 27, 2016 Jul 27, 2016

Copy link to clipboard

Copied

Trevor×… wrote:

But I don't want the numeric value I want the full enumaration string i.e.

DiacriticPositionOptions.OPENTYPE_POSITION as apposed to just OPENTYPE_POSITION

…

Hi Trevor,
I know that this thread is more than four years old, but today Marc Autret linked to it.


To answer your question—if it is not answered yet—I think, you should study Dirk Becker's enumToSource.jsx script:

enumToSource.jsx script for Adobe InDesign

Best,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jul 27, 2016 Jul 27, 2016

Copy link to clipboard

Copied

Hi Uwe

I did get the answer a few years back.

I wrote the below myself before seeing Dirks version (not nicked).

From what I remember my version has some plus points, I think that Dirk's breaks if the Enum was removed from InDesign and my one doesn't but I really don't remember well.

Thanks either way

Trevor

// script to show most of the selection properties by Trevor

// Creative-Scripts.Com (Still not ready!) available (sometimes) for custom scripts $$$

// scripts {at} Creative-Scripts [dot] Com

$.level = 0; // set debug mode to allow try catch (not read only as stated in manual);

var e;

$.writeln(getEnum(app.wordRTFImportPreferences.resolveCharacterStyleClash));

function getEnum(prop) {

    var p, n, c, i;

    getEnum.enums = getEnum.enums || {

        AcrobatCompatibility: true,

        AddPageOptions: true,

        AdornmentOverprint: true,

        AlignDistributeBounds: true,

        AlignOptions: true,

        AlignmentStyleOptions: true,

        AlternateGlyphForms: true,

        AlternatingFillsTypes: true,

        AnchorPoint: true,

        AnchorPosition: true,

        AnchoredRelativeTo: true,

        AnimationEaseOptions: true,

        AnimationPlayOperations: true,

        AntiAliasType: true,

        ArrangeBy: true,

        ArrowHead: true,

        AssetType: true,

        AssignmentExportOptions: true,

        AssignmentStatus: true,

        AutoEnum: true,

        AutoSizingReferenceEnum: true,

        AutoSizingTypeEnum: true,

        BalanceLinesStyle: true,

        BaselineFrameGridRelativeOption: true,

        BaselineGridRelativeOption: true,

        BehaviorEvents: true,

        BevelAndEmbossDirection: true,

        BevelAndEmbossStyle: true,

        BevelAndEmbossTechnique: true,

        BindingOptions: true,

        BitmapCompression: true,

        BlendMode: true,

        BlendingSpace: true,

        BookContentStatus: true,

        BookletTypeOptions: true,

        BoundingBoxLimits: true,

        BuildingBlockTypes: true,

        BulletCharacterType: true,

        BulletListExportOption: true,

        Capitalization: true,

        ChangeBackgroundColorChoices: true,

        ChangeCaseOptions: true,

        ChangeConditionsModes: true,

        ChangeMarkings: true,

        ChangeTextColorChoices: true,

        ChangeTypes: true,

        ChangebarLocations: true,

        ChangecaseMode: true,

        ChapterNumberSources: true,

        CharacterAlignment: true,

        CharacterCountLocation: true,

        CharacterDirectionOptions: true,

        ClippingPathType: true,

        ColorModel: true,

        ColorOutputModes: true,

        ColorRenderingDictionary: true,

        ColorSettingsPolicy: true,

        ColorSpace: true,

        ComposeUsing: true,

        CompressionQuality: true,

        ConditionIndicatorMethod: true,

        ConditionIndicatorMode: true,

        ConditionUnderlineIndicatorAppearance: true,

        ContainerType: true,

        ContentType: true,

        ContourOptionsTypes: true,

        ConvertPageBreaks: true,

        ConvertShapeOptions: true,

        ConvertTablesOptions: true,

        CoordinateSpaces: true,

        CopyrightStatus: true,

        CornerOptions: true,

        CreateProxy: true,

        CrossReferenceType: true,

        CursorTypes: true,

        CustomLayoutTypeEnum: true,

        DataFormat: true,

        DefaultRenderingIntent: true,

        DesignOptions: true,

        DiacriticPositionOptions: true,

        DigitsTypeOptions: true,

        DimensionsConstraints: true,

        DisplayOrderOptions: true,

        DisplaySettingOptions: true,

        DistributeOptions: true,

        DocumentIntentOptions: true,

        DocumentPrintUiOptions: true,

        DynamicDocumentsJPEGQualityOptions: true,

        DynamicDocumentsTextExportPolicy: true,

        DynamicMediaHandlingOptions: true,

        DynamicTriggerEvents: true,

        EPSColorSpace: true,

        EPSImageData: true,

        EditingState: true,

        EmptyFrameFittingOptions: true,

        EndCap: true,

        EndJoin: true,

        EpubCover: true,

        EpubVersion: true,

        EventPhases: true,

        ExportFormat: true,

        ExportLayerOptions: true,

        ExportOrder: true,

        ExportPresetFormat: true,

        ExportRangeOrAllPages: true,

        FeatherCornerType: true,

        FeatherMode: true,

        FeatureSetOptions: true,

        FindChangeTransliterateCharacterTypes: true,

        FirstBaseline: true,

        FitDimension: true,

        FitMethodSettings: true,

        FitOptions: true,

        Fitting: true,

        FlattenerLevel: true,

        Flip: true,

        FlipValues: true,

        FloatingWindowPosition: true,

        FloatingWindowSize: true,

        FollowShapeModeOptions: true,

        FontDownloading: true,

        FontEmbedding: true,

        FontStatus: true,

        FontTypes: true,

        FootnoteFirstBaseline: true,

        FootnoteMarkerPositioning: true,

        FootnoteNumberingStyle: true,

        FootnotePrefixSuffix: true,

        FootnoteRestarting: true,

        GIFOptionsPalette: true,

        GlobalClashResolutionStrategy: true,

        GlobalClashResolutionStrategyForMasterPage: true,

        GlowTechnique: true,

        GoToZoomOptions: true,

        GradientType: true,

        GridAlignment: true,

        GridViewSettings: true,

        GuideTypeOptions: true,

        HeaderFooterBreakTypes: true,

        HeaderTypes: true,

        HorizontalAlignment: true,

        HorizontalOrVertical: true,

        HyperlinkAppearanceHighlight: true,

        HyperlinkAppearanceStyle: true,

        HyperlinkAppearanceWidth: true,

        HyperlinkDestinationPageSetting: true,

        ICCProfiles: true,

        IconSizes: true,

        ImageAlignmentType: true,

        ImageConversion: true,

        ImageDataTypes: true,

        ImageExportOption: true,

        ImageFormat: true,

        ImagePageBreakType: true,

        ImageResolution: true,

        ImageSizeOption: true,

        ImportFormat: true,

        ImportPlatform: true,

        ImportedPageCropOptions: true,

        InCopyUIColors: true,

        IndexCapitalizationOptions: true,

        IndexFormat: true,

        InkTypes: true,

        InnerGlowSource: true,

        InteractiveElementsOptions: true,

        InteractivePDFInteractiveElementsOptions: true,

        JPEGOptionsFormat: true,

        JPEGOptionsQuality: true,

        JoinOptions: true,

        JpegColorSpaceEnum: true,

        Justification: true,

        KashidasOptions: true,

        KentenAlignment: true,

        KentenCharacter: true,

        KentenCharacterSet: true,

        KinsokuHangTypes: true,

        KinsokuSet: true,

        KinsokuType: true,

        LanguageAndRegion: true,

        LayoutRuleOptions: true,

        Leading: true,

        LeadingModel: true,

        LibraryPanelViews: true,

        LineAlignment: true,

        LineSpacingType: true,

        LinkStatus: true,

        ListAlignment: true,

        ListType: true,

        LiveDrawingOptions: true,

        Locale: true,

        LocationOptions: true,

        LockStateValues: true,

        MapType: true,

        MarkLineWeight: true,

        MarkTypes: true,

        MatrixContent: true,

        MeasurementUnits: true,

        MojikumiTableDefaults: true,

        MonoBitmapCompression: true,

        MoviePlayOperations: true,

        MoviePosterTypes: true,

        NestedStyleDelimiters: true,

        NoteBackgrounds: true,

        NoteColorChoices: true,

        NothingEnum: true,

        NumberedListExportOption: true,

        NumberedParagraphsOptions: true,

        NumberingStyle: true,

        OTFFigureStyle: true,

        ObjectTypes: true,

        OpenOptions: true,

        OpenTypeFeature: true,

        OutlineJoin: true,

        OverrideType: true,

        PDFColorSpace: true,

        PDFCompressionType: true,

        PDFCrop: true,

        PDFJPEGQualityOptions: true,

        PDFMarkWeight: true,

        PDFProfileSelector: true,

        PDFRasterCompressionOptions: true,

        PDFXStandards: true,

        PNGColorSpaceEnum: true,

        PNGExportRangeEnum: true,

        PNGQualityEnum: true,

        PPDValues: true,

        PageBindingOptions: true,

        PageColorOptions: true,

        PageLayoutOptions: true,

        PageNumberPosition: true,

        PageNumberStyle: true,

        PageNumberingOptions: true,

        PageOrientation: true,

        PagePositions: true,

        PageRange: true,

        PageReferenceType: true,

        PageSideOptions: true,

        PageTransitionDirectionOptions: true,

        PageTransitionDurationOptions: true,

        PageTransitionOverrideOptions: true,

        PageTransitionTypeOptions: true,

        PageViewOptions: true,

        PaginationOption: true,

        PanelLayoutResize: true,

        PanningTypes: true,

        PaperSize: true,

        PaperSizes: true,

        ParagraphDirectionOptions: true,

        ParagraphJustificationOptions: true,

        PathType: true,

        PathTypeAlignments: true,

        PdfMagnificationOptions: true,

        PerformanceMetricOptions: true,

        PlacedVectorProfilePolicy: true,

        PlayOperations: true,

        PointType: true,

        Position: true,

        PositionalForms: true,

        PostScriptLevels: true,

        PreflightLayerOptions: true,

        PreflightProfileOptions: true,

        PreflightRuleFlag: true,

        PreflightScopeOptions: true,

        PreviewPagesOptions: true,

        PreviewSizeOptions: true,

        PreviewTypes: true,

        PrintLayerOptions: true,

        PrintPageOrientation: true,

        Printer: true,

        PrinterPresetTypes: true,

        Profile: true,

        ProofingType: true,

        RangeSortOrder: true,

        RasterCompressionOptions: true,

        RasterResolutionOptions: true,

        RecordSelection: true,

        RecordsPerPage: true,

        RenderingIntent: true,

        RepaginateOption: true,

        ResizeConstraints: true,

        ResizeMethods: true,

        ResolveStyleClash: true,

        RestartPolicy: true,

        RotationDirection: true,

        RowTypes: true,

        RubyAlignments: true,

        RubyKentenPosition: true,

        RubyOverhang: true,

        RubyParentSpacing: true,

        RubyTypes: true,

        RuleDataType: true,

        RuleWidth: true,

        RulerOrigin: true,

        SWFBackgroundOptions: true,

        SWFCurveQualityValue: true,

        Sampling: true,

        SaveOptions: true,

        ScaleModes: true,

        Screeening: true,

        ScreenModeOptions: true,

        ScriptLanguage: true,

        SearchModes: true,

        SearchStrategies: true,

        SelectAll: true,

        SelectionOptions: true,

        Sequences: true,

        ShadowMode: true,

        SignatureSizeOptions: true,

        SingleWordJustification: true,

        SmartMatchOptions: true,

        SnapshotBlendingModes: true,

        SortAssets: true,

        SoundPosterTypes: true,

        SourceFieldType: true,

        SourceSpaces: true,

        SourceType: true,

        SpanColumnCountOptions: true,

        SpanColumnTypeOptions: true,

        SpecialCharacters: true,

        SpreadFlattenerLevel: true,

        StartParagraph: true,

        StateTypes: true,

        StaticAlignmentOptions: true,

        StoryDirectionOptions: true,

        StoryHorizontalOrVertical: true,

        StoryTypes: true,

        StrokeAlignment: true,

        StrokeCornerAdjustment: true,

        StrokeFillProxyOptions: true,

        StrokeFillTargetOptions: true,

        StrokeOrderTypes: true,

        StyleConflict: true,

        StyleSheetExportOption: true,

        SyncConflictResolution: true,

        TabStopAlignment: true,

        TableDirectionOptions: true,

        TableFormattingOptions: true,

        TagRaster: true,

        TagTextExportCharacterSet: true,

        TagTextForm: true,

        TagTransparency: true,

        TagType: true,

        TagVector: true,

        TaggedPDFStructureOrderOptions: true,

        TaskAlertType: true,

        TaskState: true,

        TextExportCharacterSet: true,

        TextFrameContents: true,

        TextImportCharacterSet: true,

        TextPathEffects: true,

        TextStrokeAlign: true,

        TextTypeAlignments: true,

        TextWrapModes: true,

        TextWrapSideOptions: true,

        ThumbsPerPage: true,

        TilingTypes: true,

        ToolTipOptions: true,

        ToolsPanelOptions: true,

        TrapEndTypes: true,

        TrapImagePlacementTypes: true,

        Trapping: true,

        UIColors: true,

        UITools: true,

        UndoModes: true,

        UpdateLinkOptions: true,

        UserInteractionLevels: true,

        VariableNumberingStyles: true,

        VariableScopes: true,

        VariableTypes: true,

        VersionCueSyncStatus: true,

        VersionState: true,

        VerticalAlignment: true,

        VerticalJustification: true,

        VerticallyRelativeTo: true,

        ViewDisplaySettings: true,

        ViewZoomStyle: true,

        WarichuAlignment: true,

        WatermarkHorizontalPositionEnum: true,

        WatermarkVerticalPositionEnum: true,

        WhenScalingOptions: true,

        XFLRasterizeFormatOptions: true,

        XMLElementLocation: true,

        XMLElementPosition: true,

        XMLExportUntaggedTablesFormat: true,

        XMLFileEncoding: true,

        XMLImportStyles: true,

        XMLTransformFile: true,

        ZoomOptions: true,

    };

    getEnum.nnums = getEnum.nnums || {};

    if (getEnum.nnums[+prop] !== undefined) return getEnum.nnums[+prop];

    for (n in getEnum.enums) {

        try {

            if ((p = $.global) && p.constructor.name === "Enumeration") {

                for (i in p) {

                    c = +p;

                    getEnum.nnums = n + "." + i;

                }

            }

        } catch (e) {}

    }

    if (getEnum.nnums[+prop] !== undefined) return getEnum.nnums[+prop];

    return "Enumerator UNKNOWN";

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 28, 2016 Jul 28, 2016

Copy link to clipboard

Copied

Trevor is probably referring to the previous version that touched every enum.

http://www.ixta.com/scripts/utilities/pretty.html

Regards,

Dirk

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jul 28, 2016 Jul 28, 2016

Copy link to clipboard

Copied

Hi all

Yes, Dirk, spot on, I was referring to the previous version I didn't see your new post until you pointed that out.

Very nice implementations both yours and Marc's, looks like a real improvement on both our older versions.

I now understand why Marc complimented your version above mine.

Thanks and well done!

Trevor

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 27, 2016 Jul 27, 2016

Copy link to clipboard

Copied

Hi Uwe and Trevor,

Thanks a lot!

Dirk's code sounds definitely brilliant to me, as it only relies on parsing the $.dictionary database (meaning that it properly reflects the current DOM in use), and most importantly it fixes Enumerator's prototype in a way that makes toSource() both effective and verbose, including when you invoke toSource() from a parent DOM object properties that may contain enumerators. Also, the code only instantiates NothingEnum in the global scope (in order to wake up the Enumerator constructor—a live object entity) so one can consider it very 'non-polluting' when included in a larger project or framework.

Anyway, I had fun in writing a (slightly) different implementation which (slightly) increases the verbosity. Numbers are now formatted in 0xHEXA form and the Adobe 4-char tag is shown too. Here it is:

// Repair toSource() for enumerations [alternative version]

// for InDesign CS5 and later

// -------------------------------------

// Based on Dirk Becker's 2014 original code at

// http://ixta.com/scripts/utilities/enumToSource.html

// -------------------------------------

// Output either the format

//

//     <Enumeration>.<Enumerator> /* <Hexa> [<Tag>] */

//     if <Enumeration> is the unique parent for that value,

//     e.g: AnchorPosition.INLINE_POSITION /* 414F5069 [AOPi] */

//    

// or

//

//     0x<Hexa> /* <Enumerator> [<Tag>] */

//     if Enumerator's value belongs to multiple parents,

//     e.g: 0x74787466 /* TEXT_FRAME [txtf] */

// -------------------------------------

// TIP: You can access the whole 'database' (cache)

//      browsing the following object

//      NothingEnum.NOTHING.__proto__.toSource.Q

// -------------------------------------

(function(P)

{

    P.toSource = function F(){ return F.Q[this] || "({})" };

    (function(/*obj&*/Q,  n,i,a,s,x,t,k,v)

    {

        const DIC = $.dictionary;

        const CHR = String.fromCharCode;

        const FMT = $.global.localize;

        const REGULAR_PATTERN = "%1.%2 /*\xA0%3\xA0[%4]\xA0*/";

        const SPECIAL_PATTERN = "0x%3 /*\xA0%2\xA0[%4]\xA0*/";

        for( a=DIC.getClasses(), n=a.length, i=-1 ; ++i < n ; )

        {

            x = DIC.getClass(s=a).toXML();

            if( 'true' != x.@enumeration ) continue;

            x = x.elements.property;

            for each( t in x )

            {

                k = String(t.@name);

                v = Number(t..value);

               

                Q = FMT(

                    Q.hasOwnProperty(k) ? SPECIAL_PATTERN : REGULAR_PATTERN,

                    // %1 :: Enumeration class name

                    s,

                    // %2 :: Enumerator key

                    k,

                    // %3 :: Hexa representation

                    v.toString(16).toUpperCase(),

                    // %4 :: Adobe 4-char tag

                    CHR(0xFF&(v>>>24),0xFF&(v>>>16),0xFF&(v>>>8),0xFF&(v>>>0))

                );

            }

        }

    })( P.toSource.Q={} );

})(NothingEnum.NOTHING.__proto__);

// Sample test:

// ---

alert( Locale.frenchLocale.toSource() );

// => Locale.FRENCH_LOCALE /* 4C434672 [LCFr] */

@+

Marc

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 28, 2016 Jul 28, 2016

Copy link to clipboard

Copied

Here a few notes about Marc's version:

By using the closure, you probably introduce some memory leaks. The toString() method assigned from within the closure will keep it around forever. My site has another utility based on $.summary that can point out such leaks, at http://ixta.com/scripts/utilities/summaryDifference.html - the leaks should be a workspace object (the closure) plus the outer anonymous function.

Ages ago I was warned to not use __proto__, it is not equivalent to my .prototype approach. The ExtendScript engine makes some assumptions about that object. Unfortunately I only found an old email from 2006 where I mentioned that info, but not the original quote from Michael Däumling.

Dirk

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 28, 2016 Jul 28, 2016

Copy link to clipboard

Copied

Hi Dirk,

Taking into account your informed opinion, here is an upgrade of my code safe of (workspace) leaks and using the regular constructor.prototype path. According to your great $.summary.difference() utility, its cost is now:

1 Dictionary

12 Function

1 Math

1 Enumeration

1 Enumerator

3 Object

1 Reflection

New code:

// Repair toSource() for enumerations [alternative version]

// for InDesign CS5 and later -- v.2.0

// -------------------------------------

// Based on Dirk Becker's 2014 original code at

// http://ixta.com/scripts/utilities/enumToSource.html

// -------------------------------------

// Output either the format

//

//     <Enumeration>.<Enumerator> /* <Hexa> [<Tag>] */

//     if <Enumeration> is the unique parent for that value,

//     e.g: AnchorPosition.INLINE_POSITION /* 414F5069 [AOPi] */

//    

// or

//

//     0x<Hexa> /* <Enumerator> [<Tag>] */

//     if Enumerator's value belongs to multiple parents,

//     e.g: 0x74787466 /* TEXT_FRAME [txtf] */

// -------------------------------------

// TIP: You can access the whole 'database' (cache)

//      browsing the following object

//      NothingEnum.NOTHING.__proto__.toSource.Q

// -------------------------------------

(function(/*obj&*/Q,  n,i,a,s,x,t,k,v)

{

    const DIC = $.dictionary;

    const CHR = String.fromCharCode;

    const FMT = $.global.localize;

    const REGULAR_PATTERN = "%1.%2 /*\xA0%3\xA0[%4]\xA0*/";

    const SPECIAL_PATTERN = "0x%3 /*\xA0%2\xA0[%4]\xA0*/";

    for( a=DIC.getClasses(), n=a.length, i=-1 ; ++i < n ; )

    {

        x = DIC.getClass(s=a).toXML();

        if( 'true' != x.@enumeration ) continue;

        x = x.elements.property;

        for each( t in x )

        {

            k = String(t.@name);

            v = Number(t..value);

           

            Q = FMT(

                Q.hasOwnProperty(k) ? SPECIAL_PATTERN : REGULAR_PATTERN,

                // %1 :: Enumeration class name

                s,

                // %2 :: Enumerator key

                k,

                // %3 :: Hexa representation

                v.toString(16).toUpperCase(),

                // %4 :: Adobe 4-char tag

                CHR(0xFF&(v>>>24),0xFF&(v>>>16),0xFF&(v>>>8),0xFF&(v>>>0))

            );

        }

    }

})( (NothingEnum.NOTHING.constructor.prototype.toSource=function F(){ return F.Q[this] || "({})" }).Q={} );

Best,

Marc

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jul 28, 2016 Jul 28, 2016

Copy link to clipboard

Copied

Ok my turn now

DISCLAIMERS

I did not test for memory leakages.

I did not really test for anything much at all

No fancy features like returning hex values

But for a simple answer to my question of how to get the "ColorModel" part of the "ColorModel.PROCESS" enum the below method should work even if multiple enums had the property "PROCESS" to them.

function getEnum(_enum) {

    if (getEnum.dataBase) {

        return getEnum.dataBase[_enum] || "Enumerator Unknown";

    }

    var dic, _Class, n, l, en;

    getEnum.dataBase = {};

    dic = $.dictionary.getClasses();

    for (_Class in dic) {

        en = dic[_Class];

        if (!$.global[en]) continue;

        reflection = $.global[en].reflect.properties;

        l = reflection.length - 1;

        for (n = 0; n < l; n++) {

            getEnum.dataBase[$.global[en][reflection]] = en + '.' + reflection;

        }

    }

    return getEnum.dataBase[_enum] || "Enumerator Unknown";

}

/*** USAGE ***/

var doc, rect, m;

doc = app.documents.add();

rect = doc.rectangles.add({ fillColor: doc.colors.itemByName("Cyan") });

m = [

    'Using getEnum method',

    getEnum(rect.fillColor.space),

    getEnum(rect.fillColor.model),

    'Not using getEnum method',

    rect.fillColor.space,

    rect.fillColor.model

].join('\n');

alert(m);

/********************************

    Alerts

    Using getEnum method

    JpegColorSpaceEnum.CMYK

    ColorModel.PROCESS

    Not using getEnum method

    CMYK

    PROCESS

********************************/

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 22, 2017 Mar 22, 2017

Copy link to clipboard

Copied

Hello dear scripting pros,
I am trying to get this to work, however, I always get an error in the line with $.dictionary.getClasses(): Type error: null is not an object. I tested all variations Dirk's, Marc's and Trevor's, always the same error.

So, $.dictionary is null in my case. Also I don't see where the .getClasses() method is coming from, as it is not listed in the ID object model? Do I need to make some preparations for this to work, like augment a prototype or something along these lines?

Thanks for your help.

TR

(CS6, OS X 10.8.5, German local version)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2017 Mar 22, 2017

Copy link to clipboard

Copied

Hi TR,

just tested with CS6 8.1.0 and CC 9.3.0 on OSX 10.6.8.

ESTK 4.0.0.1 with ExtendScript 4.5.5.

$.dictionary will return null with CS6.

$.dictionary will return [object Dictionary] with CC.

So this is only working with CC and above, I think.

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 22, 2017 Mar 22, 2017

Copy link to clipboard

Copied

Hi Uwe,

ah, okay. Since Marc wrote "for InDesign CS5 and later" I just assumed it would work for CS6, but then again, I should not expect that everyone checks every snippet against every version. So maybe it does work in CS5 (can't test it) and then again in CC?

Either way, thanks for the confirmation, that it does not work in CS6.

(Btw. if anyone knows a workaround for CS6 that would be great of course, but I imagine this can be quite tricky.

Thanks Uwe!

Regards,
TR

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 22, 2017 Mar 22, 2017

Copy link to clipboard

Copied

Hi TR

As a work around you could try my method in #11 that is if your aiming for the full enumerator.

Regards

TRevor

P.s. If I get a chance I'll try the $.dic method on CS5

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2017 Mar 22, 2017

Copy link to clipboard

Copied

Hi Trevor and TR,

just tested $.dictionary with CS5 and CS5.5.

To my surprise:

$.dictionary will return [object Dictionary] with CS5.5.

$.dictionary will return [object Dictionary] with CS5.

So maybe it's a bug, that $.dictionary will return null with CS6 8.1.0 ?

OSX 10.6.8

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 22, 2017 Mar 22, 2017

Copy link to clipboard

Copied

Well, what do you know?

Windows version  8.1.0.420 (CS6) works

Mac version 8.1.0.419 doesn't work

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 22, 2017 Mar 22, 2017

Copy link to clipboard

Copied

P.s. no chance of Adobe fixing that one.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines