Copy link to clipboard
Copied
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?
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);
Copy link to clipboard
Copied
Hi.
&Loc on the first line is undefined.
Copy link to clipboard
Copied
&Loc is defined and I have checked that it's value is set.
Copy link to clipboard
Copied
Did you compile using the FDK specific to each version? FM2020 is 64bit only, so that may be the cause.
Copy link to clipboard
Copied
Yes!
The plugin was originally for FM7 and I compiled for FM2015 and FM2020 using their respective FDKs.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I tried your code, but the color of the frame is not set to red.
I also tried running the sample code "objstyle" and "text" because F_ApiGetNamedObject() is used for coloring in the two samples, and the result is the coloring function not working.
Is there something wrong with the process of getting the color with F_ApiGetNamedObject()?
Copy link to clipboard
Copied
I am not sure why it's not working. I tested it with ExtendScript and it works. Try leaving off the StringT cast:
colorId = F_ApiGetNamedObject(docId, FO_Color, "Red");
Copy link to clipboard
Copied
Even leaving off the StringT cast, coloring is also not working.
I think I'll give up on coloring with plugin in FM2015......
Previously, there was a phenomenon where processing could not be performed without displaying the file with FM2015, I feel like FM2015 is not very good.
Thanks to your advice, so I was able to resolve the internal error issue.