referencing by name, not index number

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-06-11
05:03 PM
- last edited on
2023-08-07
12:22 PM
by
Doreena Deng
2004-06-11
05:03 PM
I am digging through the settings for defaults of different element types, and I found that many attributes are referenced by number, not name.
So if I want to set the font to "Arial" or the layer to "Text - Notes," I have to reference them by their index number (??!??!), not their actual name.
Is there any way around this that I'm not seeing?
Thanks!
So if I want to set the font to "Arial" or the layer to "Text - Notes," I have to reference them by their index number (??!??!), not their actual name.
Is there any way around this that I'm not seeing?
Thanks!
Tom Waltz
Labels:
- Labels:
-
Add-On (C++)
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-06-14 09:46 AM
2004-06-14
09:46 AM
Tom,
The element structures store only the indices of the attributes they refer to. The reasons behind that are synchronization and memory saving.
So, if you know the name of the attribute you'd like to set for an element, then for example in the layer case:
Akos
The element structures store only the indices of the attributes they refer to. The reasons behind that are synchronization and memory saving.
So, if you know the name of the attribute you'd like to set for an element, then for example in the layer case:
API_Attribute attr; BNZeroMemory (&attr, sizeof (API_Attribute)); attr.header.typeID = API_LayerID; CHCopyC ("Text - Notes", attr.header.name); // now see if this layer exists if (ACAPI_Attribute_Search (&attr) == NoError) { // bingo! put the index in the element's header element.header.layer = attr.header.index; } else { // exercise for the reader // e.g. create a new, or // search for another suitable layer }HTH,
Akos

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-06-14 04:08 PM
2004-06-14
04:08 PM
Akos,
that seemed to be the funciton I was looking for,
When I compiled, though, the compiler gave me an error that ACAPI_Attribute_Search () requires a header, not an attribute.
Should that line then read:
that seemed to be the funciton I was looking for,
When I compiled, though, the compiler gave me an error that ACAPI_Attribute_Search () requires a header, not an attribute.
Should that line then read:
ACAPI_Attribute_Search (&attr.header)
Tom Waltz

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2004-06-21 02:58 PM
2004-06-21
02:58 PM
TomWaltz,
Yes, you're right. That was a typo on Akos' part.
Yes, you're right. That was a typo on Akos' part.