How to get object attributes of Frame anchor?

Explorer ,
Feb 28, 2018

Copy link to clipboard

Copied

Hi all,

I need to fetch the frame anchor object attributes to prepare a list of text attributes.

Anchored Frame > Object Attributes > Text Attributes.

I tried following

    F_ObjHandleT  hGrfObjId = F_ApiGetId(FV_SessionId, docId, FP_FirstGraphicInDoc);

    /* Traverse list of graphics, anchored frames. */

    while (hGrfObjId != NULL)

    {

        UIntT  uType = F_ApiGetObjectType(docId, hGrfObjId);

        if (uType == FO_AFrame)

        {

            F_AttributesT attribList = F_ApiGetAttributes(docId, hGrfObjId);

            for (UIntT i = 0; i < attribList.len; i++)

            {

                F_Printf(NULL, "Attribute %d: %s ||| %s.\n", i, attribList.val.name, attribList.val.values);

            }

        }

        hGrfObjId = F_ApiGetId(m_doc.getDocId(), hGrfObjId, FP_NextGraphicInDoc);

    }

All seems to be inline as per fdk but I never get anything in from F_ApiGetAttributes(). It always returning len = 0 and val = null.


Am I missing anything here? If this is not correct way of extracting attributes, please suggest me right way.

Thank you.

Regards,

Paresh

TOPICS
Scripting

Views

417

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mentor ,
Mar 05, 2018

Copy link to clipboard

Copied

Hi Paresh,

You are confusing the terms "attributes" and "properties," at least in the context of FrameMaker scripting. An "attribute" is a structural attribute on an element in a structured document. F_ApiGetAttributes() is the function to get those attributes. So, it is only applicable when called on an element object.

To get a property, you would ask for that property directly, with an F_ApiGet...  function that applies to the property type. For example, to get the parent frame which is an object:

F_ObjHandleT parentFrame;

parentFrame = F_ApiGetId(docId, hGrfObjId, FP_InTextFrame);

You can get a list of all properties with:

F_PropValsT props;

props = F_ApiGetProps(docId, hGrfObjId);

You can iterate through all the properties with this structure. It is uncommon to do that, though (I think) and the PropValsT structure is not particularly friendly to work with directly. But you could loosely replicate the example you presented using that.

Hope this helps.

Russ

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Mar 06, 2018

Copy link to clipboard

Copied

Hi Russ,

Thank you for the attribute vs property clarification.

I tried your suggestion but it fails badly for anchored frame.

Following crashes fm if hGrfObjId is anchored frame.

props = F_ApiGetProps(docId, hGrfObjId);

Any Clue?

Regards,

Paresh

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mentor ,
Mar 06, 2018

Copy link to clipboard

Copied

Hi Paresh,

I am able to replicate the crash. I think it is a bug and likely there is nothing we can do about it. By reading the documentation, I don't see any reason that it should not work for an anchored frame.

Perhaps there is a workaround or another way to reach your goal. If it is not too complicated, could you explain why you want to retrieve all properties from an anchored frame?

Russ

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Mar 06, 2018

Copy link to clipboard

Copied

Could you please tell me what I can try to get values in object attribute of anchor frame? This is just an sample I have document with many defined attributes.

@Russ, I am trying to build my own custom xml from fm document hence trying to get the properties.

Re: FrameMaker &gt; XML

@Rick, Its rare but was an easy choice to get all detail in one go.

Thanks,

Paresh

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Mar 06, 2018

Copy link to clipboard

Copied

@Russ, your pointer helped and questions help me figure our the solution


Following line gave me all values inside anchor object attributes.
F_StringsT attrList = F_ApiGetStrings(docId, hGrfObjId, FP_ObjectAttributes);

Cheers,

Paresh

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mentor ,
Mar 07, 2018

Copy link to clipboard

Copied

Hi Paresh,

I totally did not realize that you meant this type of attribute! I had forgotten all about that feature. Indeed, the UI calls them attributes. In any case, I'm glad to hear you got it figured out.

Russ

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Mar 06, 2018

Copy link to clipboard

Copied

As Russ said, it is rare that you need to get all of the properties at once. Usually, you just query the property or properties that you are interested in. For example,

// Get the text frame that contains the anchored frame.

textFrame = F_ApiGetId (doc, hGrfObjId, FP_InTextFrame);

Likes

Translate

Translate

Report

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