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

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

Community Beginner ,
Feb 28, 2024 Feb 28, 2024

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.

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

TOPICS
Error
882
Translate
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

correct answers 1 Correct answer

Community Expert , Mar 04, 2024 Mar 04, 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);
Translate
Participant ,
Feb 29, 2024 Feb 29, 2024

Hi.

&Loc on the first line is undefined.

Translate
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 Beginner ,
Mar 03, 2024 Mar 03, 2024

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

Translate
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
Participant ,
Mar 03, 2024 Mar 03, 2024

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

Translate
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 Beginner ,
Mar 03, 2024 Mar 03, 2024

Yes!

The plugin was originally for FM7 and I compiled for FM2015 and FM2020 using their respective FDKs.

Translate
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 04, 2024 Mar 04, 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.

Translate
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 04, 2024 Mar 04, 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);
Translate
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 Beginner ,
Mar 05, 2024 Mar 05, 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?

Translate
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 05, 2024 Mar 05, 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.

 

Translate
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 Beginner ,
Mar 05, 2024 Mar 05, 2024

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()?

Translate
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 06, 2024 Mar 06, 2024

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");
Translate
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 Beginner ,
Mar 07, 2024 Mar 07, 2024
LATEST

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.

Translate
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