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

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

Community Beginner ,
Feb 28, 2024 Feb 28, 2024

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.

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

TOPICS
Error

Views

168

Translate

Translate

Report

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);

Votes

Translate

Translate
Explorer ,
Feb 29, 2024 Feb 29, 2024

Copy link to clipboard

Copied

Hi.

&Loc on the first line is undefined.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Yes!

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

Votes

Translate

Translate

Report

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

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.

Votes

Translate

Translate

Report

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

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);

Votes

Translate

Translate

Report

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

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?

Votes

Translate

Translate

Report

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

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.

 

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

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");

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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