Hi everyone,
I’m trying to figure out the correct way to place a macro from the Macros window into a Layout via XML / ActionScript.
So far I tried something like this:
<step>Layouts.AddLayoutElements(handle:"Location=Layouts,1,1",
handles:"Location=Macros,1,11",
x:0, y:0)</step>
…but it doesn’t seem to work. The macro gets selected, but nothing is actually added to the Layout.
I also tried with Handles.SetSourceHandleFromHandle before calling AddLayoutElements, but still no success.
What is the correct method to either copy a macro into a Layout or transfer/link it there programmatically? Do I need to use AddSelectedHandleToLayout, or is there another approach for macros specifically?
How to copy/transfer a macro into a Layout using AddLayoutElements?
Moderator: Moderators
Re: How to copy/transfer a macro into a Layout using AddLayoutElements?
Please try the following:
In macro scripts handle: or similar indicates that the value should be converted to the type preceding the colon. This is only necessary if an conversion cannot be detected automatically so in the above although you could write handle:"Location=Layouts,1,1" for the first parameter, this is inferred by the type the function is expecting. In the case of the second parameter there are two steps to the conversion, the first is to convert the string to a single handle and the second (which is again inferred) is to convert that into a list of multiple handles (even though the list only contains a single item). If a cast is not specified the software will attempt to split the string on the commas and then convert each part as a separate handle which wouldn't work when the parts are supposed to form a location.
Code: Select all
<step>Layouts.AddLayoutElements("Location=Layouts,1,1", handle:"Location=Macros,1,11", 0, 0)</step>
In macro scripts handle: or similar indicates that the value should be converted to the type preceding the colon. This is only necessary if an conversion cannot be detected automatically so in the above although you could write handle:"Location=Layouts,1,1" for the first parameter, this is inferred by the type the function is expecting. In the case of the second parameter there are two steps to the conversion, the first is to convert the string to a single handle and the second (which is again inferred) is to convert that into a list of multiple handles (even though the list only contains a single item). If a cast is not specified the software will attempt to split the string on the commas and then convert each part as a separate handle which wouldn't work when the parts are supposed to form a location.
Who is online
Users browsing this forum: No registered users and 96 guests