Hello vwnisus
Since the task you are trying to achieve will require the macro language and use of the macro objects, it's usually a good idea to start with the following line:
This gives you a "hold" on the Nisus document object, through which you access everything else. For example you will need the table that you have selected. After the above command you can get that as follows:
Code: Select all
$sel = $doc.tableSelection
$table = $sel.table
Now what can you do with the
$table? For one thing you can select it, like this:
Ok, now on to your problem. You made a good start here:
vwnisus wrote:I have a Nisus document with several tables.
For 2. do I need to use
Code: Select all
LineAttributes.newWithLineType styleName
?
Even if I do it is not clear how to write the line of macro code (as the description indicates "Returns line attributes that draws using one of the given named styles:", i.e. indicates an attributable but not applies it).
Well what that last bit means is that you need to assign the line attributes to something, for example a variable:
Code: Select all
$solid = LineAttributes.newWithLineType "solid"
With that line you have solid line attributes in the variable
$solid. Now you're ready to apply the line attributes to something. There are two options:
- The cell object has a command .setLineAttributesForEdges (note the "set" and the plural here)
- The table selection object has a command .applyLineAttributesToEdges (note the "apply" here)
If you read the fine print on these two, you'll notice that there are some differences, and you'll quickly see that the latter will be way more convenient in your case. But it requires that we have (A) a table selection, and (B) that that selection encompass the entire table.
The reason why I stress this point is that earlier I already retrieved a table selection (with the command "$sel = …"). The only problem is that that selection is whatever you may have clicked before starting the macro. So it might just be one cell of the table. But now we do have the whole table selected, so we can easily retrieve a new table selection that covers the whole table.
Code: Select all
$sel = $doc.tableSelection # update $sel to encompass the whole table
$sel.applyLineAttributesToEdges $solid, "Normal"
(The "Normal" means all the orthogonal edges. Look in the Macro Language Reference for other possible patterns.)
OK. So let's put it all together.
Code: Select all
$doc = Document.active
$sel = $doc.tableSelection # Get the selection
$table = $sel.table
$doc.setSelection $table # Select the whole table. Could have done this with "Select Table" instead
$solid = LineAttributes.newWithLineType "solid" # Create the line attributes
$sel = $doc.tableSelection # Update $sel to encompass the whole table
$sel.applyLineAttributesToEdges $solid, "Normal" # Apply the line attributes to the table
Ok. Now the only thing left is the padding. Piece of cake. And here we find … [drumroll] …

There is no way to do it ! Yeah, that's right. I guess the programmer dude at Nisus was out surfing that day
There is no menu command to control padding, and no macro command either. So that's a bummer. Somebody once tried using AppleEvents to click in the drawer, but short of that you're just going to have to do it by hand after the macro finishes.
Anyhow hope that helps
PS: Once you get used to the macro language, you'll see that you can write the whole thing a little more compactly without all those variables, like this:
Code: Select all
Select Table
$doc = Document.active
$doc.tableSelection.applyLineAttributesToEdges(LineAttributes.newSolid, 'Normal')
