11-27-2012 09:50 AM
Good morning,
I'm writing a script meant to create a default report with a variable number of pages.
For that, I'm using DIAdem objects to create these new pages but i got stuck trying to properly configure some textbox.
I'd like to display a data root property in all the pages ,remember the pages are being created as the script goes. "In theory" , this value is an user input (get through a DlgBox when the script is running) so what I did was to assing the value: Data.Root.Properties("Report_Number").Value to the new text object (by using the TXTTXT command).
By doing this the new report shows the value (as a plain text, no longer linked to the property) which is fine as long as the user knew that value . But here is the problem, sometimes this value cannot be specified until the last moment so the users may have to change it and now it's not as simple as change the property value and click refresh. He/She would need to go one by one in order to change this "number".
I was thinking in creating either a new non-modal dialog box or a new buttom which opens/closes all these objects refreshing their values text but before move forward I'd like to know if there is something easier to keep the link between the property value and the text object.
p.S. I'm using DIAdem 11
Thanks
Javier
Solved! Go to Solution.
11-28-2012 01:49 PM
Hey Javier,
Have you created a .TDR file to base these appended report pages off of? I'm looking at one of the DIAdem examples (Help > Examples > Creating Scripts > scripts > Brake Tests for Trucks) which does something very similar as far as creating a report and appending pages to it within a report. Basically, there's a .TDR file which defines the layout of that report and what items are contained in it. When creating that TDR file, you can simply click and drag a property from the Data Portal into the report, and it will create a text box which links to that property.
Here's an example of the syntax used for this linking:
@@Data.Root.ChannelGroups(GraphSheetCurrNo).Properties("RoadSurface").Value@@
I noticed that you didn't include the @@ in your message, but I'm not sure if that's actually how your code is or just formatting to make it easier for us to read. Would it be possible to see the snippet of code that actually sets that value?
I would think that it would be possible to just link the textbox to the property when creating the TDR file in the Report view, and that should keep it dynamically linked to the property in the data portal.
I hope that helps some, and if you're still having trouble with it, it'd be great if we could see the snippet of your script file that's dealing with the textbox.
11-28-2012 03:27 PM
Daniel thanks for your quick response,
I 've have a look to this example. The example uses a different approach to create a multi-page report as I do which may be the good one. There, a TDR is generated, save and the following pages are appended using the PicFileAppend command.Then it's possible to open the different objects and set the properties, axis,channels....
By doing this I notice that the properties keep the dynamic link. However I'm trying to do something slighlty different...
Here is what I did;
In order to create a multi-report page I use a loop
For i=1 to nUnits ' Number of pages
.....
.....
....
Call Check 'Subrutine to check if the group has the neccesary channels
Call addsheet("Title") 'Subrutine that adds the new pages ( There is no TDR)
If ok=true then
Call graph("ct_"+Str(Data.Root.ChannelGroups(index_+i+a).Properties("index").Value),"top",0,4,0.5,4,200,350,50,4,"["&index_+i+a&"]/MITo"," ["&index_+i+a&"]/"&ChPP_&"", "Input Force [N]", "Travel [mm]") 'Subrutine that creates a new graph and adds the proper channels on it ( There is no TDR)
....
....
.... .
a=a+1*Step_
unit=unit+1
Next
Which also works but....does not keep dynamic links when writing a property (see below): (Basically, i'm trying to add a text box to all the pages that the script has previously generated)
For t=1 to GraphSheetcount
name=GraphSheetNGet(t)
if name <> "After endurance tests" then
Call GraphSheetRefSet(name)
Call GraphObjNew("FreeText","Report name")
Call GraphObjOpen("Report name")
TXTFONT = "Arial"
TXTRELPOS = "cent."
TXTPOSX = 50
TXTPOSY = 93
TXTSIZE = 2.2
If Data.Root.Properties.Exists("Report_Number") then TXTTxt = Data.Root.Properties("Report_Number").Value ' Which appears as a plain text
Call GraphObjClose("Report name")
End if
Next
That also works, but the text lose its dynamic link, is there any way to "drop" a property value trough the script view and keep the dynamic link?
After writting this e-mail i think I could just append a blank page which cointains the property
Regards,
Javier
11-29-2012 03:19 PM
Hey Javier,
I'm still looking into this to see if there's a way to insert the property with a script and maintain the link, but I think that using the method from the example of creating a TDR file and having the script call it might be a better approach to the problem, both for the purpose of getting the property to link and also for general ease of use in the future.
I'll let you know if I come up with any other ideas for linking the property and the textbox, and please let us know if the TDR solution isn't appropriate for your situation or if you run into any more problems.
11-29-2012 05:30 PM
Thanks again Daniel,
Yeah, I made it following your suggestion. Create a TDR with just the already mentioned property and appending it instead of a blank page and...works fine!!
I didn't follow this approach since the beggining of the proyect because I had many (many) combinations for single TDR, so was easier for me using "Loops" for creating the objects (or to be able to create them. Some of these combination are rarely be used!) instead of having thousands of TDRs. In fact, I assumed that I'd save time maintaing the program just modifying some lines instead of open/change/save all the TDRs. I don't know, I may be wrong. (so late to change!!!
As for now, I'll use this weird "combination". But if you find out how to link a property from the script console I will appreciate!!! (More to satisfy my curiosity)
Thanks!!!!
Javier
11-30-2012 11:48 AM
Javier,
I think I figured it out!
You simply need to send the property to the textbox as a variable instead of just as text. Here's an example
TXTTXT = "@@Data.Root.Properties(""Report_Number"").Value@@"
You can see that I added the @@ on each end of the property, and also quoted the string so that the script will interpret it properly. I also had to double-quote the Report_Number string so that the VB script would interpret it properly.
Give that a try and let me know how it goes--I think it should work great for you. After running the script, I can change the property and then refresh the report and see the updated value.
11-30-2012 01:54 PM
You rock man!!
Thanks!! It works perfectly!!
Javier