Skip to main content
Participating Frequently
February 29, 2024
Answered

Internal error occurs when getting the property of anchored frame with FM2015

  • February 29, 2024
  • 3 replies
  • 909 views

Hi.

 

I have a plugin working with FM2015.

I use the following code to add an anchored frame and change the property.

AFrameId = F_ApiNewAnchoredObject(docId, FO_AFrame, &Loc);
props = F_ApiGetProps(docId, AFrameId);
j = F_ApiGetPropIndex(&props, FP_AnchorType);	
props.val[j].propVal.u.ival = FV_ANCHOR_SUBCOL_LEFT;
j = F_ApiGetPropIndex(&props, FP_Fill);
props.val[j].propVal.u.ival = FV_FILL_WHITE;
...

F_ApiSetProps(docId, AFrameId, &props);
F_ApiDeallocatePropVals(&props);

After running F_ApiGetProps(), the following internal error occurs.


This plugin works well with FM2020, but not FM2015.
Is there a way to solve this?

This topic has been closed for replies.
Correct answer frameexpert

I suspect that the problem is with the way you are getting and setting properties. Instead of getting, updating, and setting the properties using props, try changing them directly, like this:

F_ApiSetInt(docId, AFrameId, FP_Fill, FV_ANCHOR_SUBCOL_LEFT);
F_ApiSetInt(docId, AFrameId, FP_Fill, FV_FILL_WHITE);

3 replies

frameexpert
Community Expert
frameexpertCommunity ExpertCorrect answer
Community Expert
March 4, 2024

I suspect that the problem is with the way you are getting and setting properties. Instead of getting, updating, and setting the properties using props, try changing them directly, like this:

F_ApiSetInt(docId, AFrameId, FP_Fill, FV_ANCHOR_SUBCOL_LEFT);
F_ApiSetInt(docId, AFrameId, FP_Fill, FV_FILL_WHITE);
AIAIAIAuthor
Participating Frequently
March 5, 2024

I followed your idea and succeeded in setting the property with no inteanal error.

But,  another problem occures.

 

I want to set  the anchored frame's color, so I use the following code.

But this code failed, the frame's color is set to black.

colorId = F_ApiGetNamedObject(docId, FO_Color, (StringT)"Red");
F_ApiSetId(docId, AFrameId, FP_Color, colorId);

I also tried the following code, but it also failed, the frame's color is set to black.

colorId = F_ApiGetNamedObject(docId, FO_Color, (StringT)"Red");
setVal.propIdent.num = FP_Color;
setVal.propVal.valType = FT_Id;
setVal.propVal.u.ival = colorId;
F_ApiSetPropVal(docId, AFrameId, &setVal);

I found that after running F_ApiGetNamedObject(), the colorId is always set to 0, even I set the color to Red, bule, or Magenta.

 

Is there something wrong with my code?

frameexpert
Community Expert
Community Expert
March 5, 2024

Try this:

 

F_ApiSetInt(docId, AFrameId, FP_Fill, FV_FILL_BLACK);
colorId = F_ApiGetNamedObject(docId, FO_Color, (StringT)"Red");
F_ApiSetId(docId, AFrameId, FP_Color, colorId);

A graphic object has to be filled with black before a color can be applied to it.

 

frameexpert
Community Expert
Community Expert
March 4, 2024

I would comment out a few lines, recompile, and test again. For example,

//j = F_ApiGetPropIndex(&props, FP_AnchorType);	
//props.val[j].propVal.u.ival = FV_ANCHOR_SUBCOL_LEFT;
//j = F_ApiGetPropIndex(&props, FP_Fill);
//props.val[j].propVal.u.ival = FV_FILL_WHITE;

You want to determine what is actually making it crash.

Participating Frequently
March 1, 2024

Hi.

&Loc on the first line is undefined.

AIAIAIAuthor
Participating Frequently
March 4, 2024

&Loc is defined and I have checked that it's value is set.

Participating Frequently
March 4, 2024

Did you compile using the FDK specific to each version? FM2020 is 64bit only, so that may be the cause.