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

Add elements to doc

Community Beginner ,
Jun 25, 2014 Jun 25, 2014

Copy link to clipboard

Copied

Hi,

I want to know if this is possible to manipulate fm objects to add existing elements (instanciated objects) to a document.

I saw multiple ways to create doc objects but I can't found any way to add it anything but text.

I saw in the api some functions to create new elements, F_ApiNewGraphicObject(), F_ApiNewAnchoredObject(), F_ApiNewElement()... but none to add an existing element...

Is there a way to do that ? If not is it possible to clone an object ?

TOPICS
Scripting

Views

1.1K

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

Mentor , Jun 25, 2014 Jun 25, 2014

Hi,

To insert a completely new element, you would use F_ApiNewElement() or F_ApiNewElementInHierarchy(). For some reason, neither of these appear in the PDF bookmarks of the latest FDK reference, but they are described in the text.

You also say something about an "existing" element and "cloning", so I'm not exactly clear on what you want. To copy an existing element, you can select it and use F_ApiCopy() / F_ApiPaste.

One thing I would note, though, is that you are using words that are associated

...

Votes

Translate

Translate
Mentor ,
Jun 25, 2014 Jun 25, 2014

Copy link to clipboard

Copied

Hi,

To insert a completely new element, you would use F_ApiNewElement() or F_ApiNewElementInHierarchy(). For some reason, neither of these appear in the PDF bookmarks of the latest FDK reference, but they are described in the text.

You also say something about an "existing" element and "cloning", so I'm not exactly clear on what you want. To copy an existing element, you can select it and use F_ApiCopy() / F_ApiPaste.

One thing I would note, though, is that you are using words that are associated with objects in an object-oriented program. FrameMaker objects are not really the same... they are just things in the session that have properties. There is no real concept of "cloning" or "instantiation" with a FrameMaker object.

Russ

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 ,
Jul 17, 2014 Jul 17, 2014

Copy link to clipboard

Copied

Hi,

adding elements seems to be not so simple. The element object offers only delete and no add method.

How do you use in ES commands from the FDK (like F_ApiNewElement() or F_ApiNewElementInHierarchy())? Unfortunately I could not find anything useful about this. Or is it definitely in ES completely different how to add elements?

Thank you for your any pointer.

Regards,

Apollo102

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 ,
Jul 18, 2014 Jul 18, 2014

Copy link to clipboard

Copied

NewElement() is a method of an ElementDef object. So to add an element at the current insertion point, you can do something like this:

#target framemaker

var doc = app.ActiveDoc;

var elementDef = doc.GetNamedElementDef ("p");

var element = elementDef.NewElement (doc.TextSelection.beg);

Rick

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 ,
Jul 18, 2014 Jul 18, 2014

Copy link to clipboard

Copied

LATEST

Hi Rick,

thank you very much. It works perfectly. It is also doing the validation.

Apollo102

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