Jump to content

Set Custom Sheet Data via script


spettitt

Recommended Posts

We have some custom sheet data set up in our template. I'm trying to interact with them via script, but can't find the way to it.

 

I've tried

vs.SetRField(TitleBlockBorderHandle, 'Title Block Sheet Data', 'CustomField', myvalue)

and the same pointing to the handle of the sheet layer itself, but neither work.

 

I can set the Sheet Layer Title via selector #159, but have no way of knowing the select for a custom sheet data field.

 

Any pointers please?

Link to comment

What you are doing should work.  I use a Worksheet and Create Report to display all the fields in the Sheet Data including my custom field and what I got for the Custom Field was"

 

='Title Block Sheet Data'.'Custom Field'

 

So your SetRField should work.

 

This worked for me in VW2024 Vectorscript with the TBB as the only selected object.  Not tested in VW2023 but it should be the same.

 

SetRField(FSActLayer, 'Title Block Sheet Data', 'Custom Field', 'Test Value');

 

 

Link to comment

Thanks @Pat Stanford. I can get your example to work. However in my case, I'm creating the sheet and title block border in the script and then using that handle straight away to get/set the sheet data. Maybe the TBB hasn't fully initialised when I try to access it's data.

 

I'm just trying to pull the default value for the moment and then I can switch to writing the intended value.

 

I've tried:

sheetlayh = vs.CreateLayer('SheetNo', 2)
tbb = vs.CreateCustomObjectN('Title Block Border', 0, 0, 0, False)
vs.SetPluginStyle(tbb, 'Our A3 Style')
vs.ResetObject(tbb)
check = vs.GetRField(vs.LNewObj(), 'Title Block Sheet Data', 'Series')
vs.AlrtDialog('ser = ' + str(check))

 

But it returns a blank value.

 

I've tried running a function to create a single extra sheet, then a function that returns the custom field for each sheet in turn. This successfully brings back the custom value for the existing 4 sheets, but not the recently created sheet.

 

def createsheet():
    sheetlayh = vs.CreateLayer('MySheet', 2)
    tbb = vs.CreateCustomObjectN('Title Block Border', 0, 0, 0, False)
    vs.SetPluginStyle(tbb, 'Our A3 Style')
    vs.ResetObject(tbb)
    # check = vs.GetRField(vs.LNewObj(), 'Title Block Sheet Data', 'Series')
    # vs.AlrtDialog('ser = ' + str(check))
    # vs.SetRField(tbb, 'Title Block Sheet Data', 'Series', 'dddd')


def getsheetdata(h):
    check = vs.GetRField(h, 'Title Block Sheet Data', 'Series')
    vs.AlrtDialog('ser = ' + str(check))


createsheet()

vs.ForEachObject(getsheetdata, "PON = 'Title Block Border'")

 

If I comment out the call to 'createsheet()' and run the script again, the value for the 5th TBB does return fine.

 

So it's almost like the TBB fully initialises itself at the end of the script, and that data is then available when future scripts are called. If it has to be two scripts then so be it, but it would be nice if there were a way to do this.

 

Thanks

 

Simon

Edited by spettitt
Link to comment

There is definitely an issue with objects created in a script not "existing" until the completion of the script run.

 

I don't have time to dig in deeply right now, but try a vs.redraw or vs.redrawall after the TBB creation and see if that helps. Those calls are supposed to draw objects that are created in the script and make them accessible (at least to set their selection state). 

 

I have never figured out which incantation is really necessary so I have a lot of scripts floating around with some combination of

 

Redraw

RedrawAll

ResetObject

 

Once I find a version that works I just use it and don't worry about the extra overhead.

Link to comment

Thanks both. Unfortunately none of those seem to change the situation. I've thrown them all at it and no luck so far.

 

        tbb = vs.CreateCustomObjectN('Title Block Border', 0, 0, 0, False)
        vs.SetPluginStyle(tbb, 'A3R')
        vs.ResetObject(tbb)
        vs.ReDraw()
        vs.ReDrawAll()
        vs.ResetBBox(tbb)
        vs.AlrtDialog('ser = ' + vs.GetRField(tbb, 'Title Block Sheet Data', 'Series'))
        vs.SetRField(tbb, 'Title Block Sheet Data', 'Series', 'dddd')

 

I've even tried getting the script to do some other stuff and then run another function using ForEachObject = TBB to try and access even the default data, but nothing. Only once the script is fully finished and another run 😕

Link to comment
  • Marionette Maven

The post Pat shared I believe is your missing link.

 

Throw 

vs.SetObjectVariableBoolean(tbb, 1167, True)

into your script after you've created the TBB, but before trying to pull/push information to it.

It appears to be working on my end.

 

I remember having to use this when I was writing a script my first year at VW to output an animation of a door opening, sending me back to my early years 😛 

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...