Skip to main content
Inspiring
March 1, 2018
Question

How to get object attributes of Frame anchor?

  • March 1, 2018
  • 1 reply
  • 1103 views

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

This topic has been closed for replies.

1 reply

Legend
March 5, 2018

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

Inspiring
March 6, 2018

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

Legend
March 6, 2018

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