The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (API DevKit) for independent software developers

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, gkmethy, Tibor Lorántfy, rmasaki, MOREH Tamas, Akos Somorjai, Ed Brown, Mihály Palenik

#304556
To describe a text paragraph, one must use the API structure of API_ParagraphType which would normally be wrapped as a APIObject() in Archicad's Python. The structure is:
Code: Select all
typedef struct {
        Int32           from;
        Int32           range;
        API_JustID      just;
        Int32           filler_1;
        double          firstIndent;
        double          indent;
        double          rightIndent;
        double          spacing;
        API_TabType     *tab;
        API_RunType     *run;
        Int32           *eolPos;
        Int32           filler_2;
        double          width;
        double          height;
        double          filler_3[2];
    } API_ParagraphType;
Note: that the first variable, a Int, is named "from" which is a keyword in Python and not usable for reference.Therefore,it's not possible to create a wrapped paragraph python object.The actual code would parallel the example for "rich text" shown in the Element_Test example Add On. BUT its not now possible to create a paragraph object because of this conflict. Any workarounds? (Other than breaking the document up into separate draw segment, which would be a PITA) It might be simpler if Graphisoft would implement HTML or the other inline web format such as "markdown"?
#304567
poco2013 wrote:
Wed Dec 04, 2019 1:18 pm
To describe a text paragraph, one must use the API structure of API_ParagraphType which would normally be wrapped as a APIObject() in Archicad's Python. The structure is:

Note: that the first variable, a Int, is named "from" which is a keyword in Python and not usable for reference.Therefore,it's not possible to create a wrapped paragraph python object.The actual code would parallel the example for "rich text" shown in the Element_Test example Add On. BUT its not now possible to create a paragraph object because of this conflict. Any workarounds? (Other than breaking the document up into separate draw segment, which would be a PITA) It might be simpler if Graphisoft would implement HTML or the other inline web format such as "markdown"?
If I understand correctly you are trying to create plain text, the only thing I know can be seen in "DoElementTest.py"
Code: Select all
def DrawText(x, y, text):
    element = APIObject()
    element.head = APIObject()
    element.head.typeID = API_TextID
    element.head.hasMemo = True
    element.loc = APIObject()
    element.loc.x = x
    element.loc.y = y
    memo = APIObject()
    memo.textContent = text
    return CreateText(element, memo)
#304573
I would like to ask for an additional qualification regarding getting information about elements. In previous example mr.Mikhail suggested using
guid = ClickElement()
element = GetWall(guid)
structure, where one could type element.List() in order to get information and idea what properties one could use. However, how do you apply that to other objects in archicad? How would you get for example window instead of wall, when there is not GetWindow (guid) function, or GetDoor(guid) or anything similar? Or am I missing something? I was not able to find GetWall(guid) function neither in the help file.
#304574
If I understand correctly you are trying to create plain text, the only thing I know can be seen in "DoElementTest.py"
Nope -- I am trying to recreate "rich text" or as Graphisoft defines it - "multistyle Text". Multistyle uses a API_ParagraphType structure which , as i mentioned can not be used in Python because of the use of the "from" keyword.
#304579
Petar.Pejic wrote:
Wed Dec 04, 2019 7:07 pm
I would like to ask for an additional qualification regarding getting information about elements. In previous example mr.Mikhail suggested using
guid = ClickElement()
element = GetWall(guid)
FYI-- There is no GetWindow/GetDoor implementation YET in Archicad's Python. Since this only a experiment I assume that only a representative sample of functions were provided and more is yet to come.

However, note that the API GetElement function returns the parameters of the element. Properties describe the element. In many cases the element's parameters are duplicated in it's 'builin' properties. You may find what you need in looking through the door/window properties which you can do using the python function:

GetElementPropertyDefinitionDictionary(elem,filterID) The filter should be set to '....._All' which will give all the BuiltIn properties. May not be what you need but worth a look?
#304599
Petar.Pejic wrote:
Wed Dec 04, 2019 7:07 pm
I would like to ask for an additional qualification regarding getting information about elements. In previous example mr.Mikhail suggested using
guid = ClickElement()
element = GetWall(guid)
structure, where one could type element.List() in order to get information and idea what properties one could use. However, how do you apply that to other objects in archicad? How would you get for example window instead of wall, when there is not GetWindow (guid) function, or GetDoor(guid) or anything similar? Or am I missing something? I was not able to find GetWall(guid) function neither in the help file.
There is an example "ListClickedElementMembers.py".
Inside is used GetElement (), which is not in the documentation, works with almost all types of elements
#304600
poco2013 wrote:
Wed Dec 04, 2019 7:45 pm
If I understand correctly you are trying to create plain text, the only thing I know can be seen in "DoElementTest.py"
Nope -- I am trying to recreate "rich text" or as Graphisoft defines it - "multistyle Text". Multistyle uses a API_ParagraphType structure which , as i mentioned can not be used in Python because of the use of the "from" keyword.
I understood. Sorry, I still do not know English well and the translator does not always help :(
Probably have to wait for individual functions to work with multitext.
As with many others.
I tried, something to throw on API_ParagraphType, but without successfully

UPD. If it helps. See attachment
UPD2. API_ParagraphType should be passed to memo
Attachments
different text - multitext.jpg
about paragraphtype.jpg
#304603
Thank you all for explaining that in more detail.
mr.Mikhail, what sort of help you need?

Edit: ListClickedElementMembers.py seams to work only for walls, it does not recognize any other elements when clicked (windows, doors, columns, roofs, slabs). Only walls. Is it just me, or others have that issue as well?
Last edited by Petar.Pejic on Thu Dec 05, 2019 9:11 am, edited 1 time in total.
  • 1
  • 3
  • 4
  • 5
  • 6
  • 7