[Smtk-developers] Help

Shukla, Indu ERDC-RDE-ITL-MS Indu.Shukla at erdc.dren.mil
Fri Jun 26 15:31:08 EDT 2015


David,

Tide and wind and the tabular entries in my form.  There will be no fixed number of entries for tide and wind, they can vary according to the situation. In this test example I sent you, I  only have  one each for tide (Tide-0) and wind (Wind-0). 
I need to know,
1. How many of tide entries are there
2. How many wind entries are there.
3. Then access the items(Gage Station,{Station,Agency,Station ID}) and its values (Gage Station,{station,0,1234})  of each tide and wind entries. 

Thanks,

Indu

-----Original Message-----
From: David Thompson [mailto:david.thompson at kitware.com] 
Sent: Friday, June 26, 2015 2:19 PM
To: Shukla, Indu ERDC-RDE-ITL-MS
Cc: Yumin Yuan; smtk-developers at smtk.org; Hines, Amanda M ERDC-RDE-ITL-MS
Subject: Re: [Smtk-developers] Help

Hi Indu,

I'm a little unclear on exactly what information you want to get from the "Tide-0" attribute.

	David

> On Jun 26, 2015, at 3:16 PM, Shukla, Indu ERDC-RDE-ITL-MS <Indu.Shukla at erdc.dren.mil> wrote:
> 
> David, Yumin,
> 
> This code 
> 
> att = asys.findAttribute('Globals')
> gr = att.findGroup('ProjectInformation')
> nm = smtk.attribute.to_concrete(gr.find('ProjectName'))
> #print nm.value(0) 
> 
> Works great to access the InstanceView items. How to I access items and its values in attribute view? Here's my example.
> 
>    <Att Name="Tide-0" Type="Tide" ID="6">
>      <Items>
>        <Group Name="Gage Station">
>          <String Name="Station">station</String>
>          <String Name="Agency" Discrete="true">0</String>
>          <String Name="Station ID">1234</String>
>        </Group>
>        <Group Name="Latitude">
>          <String Name="Degree">0</String>
>          <String Name="Minutes">0</String>
>          <String Name="Seconds">0</String>
>          <String Name="Directions" Discrete="true">0</String>
>        </Group>
>        <Group Name="Longitude">
>          <String Name="Degree">0</String>
>          <String Name="Minutes">0</String>
>          <String Name="Seconds">0</String>
>          <String Name="Directions" Discrete="true">0</String>
>        </Group>
>        <String Name="Description">
>          <UnsetVal />
>        </String>
>      </Items>
>    </Att>
> 
>    <Att Name="Wind-0" Type="Wind" ID="7">
>      <Items>
>        <Group Name="Gage Station">
>          <String Name="Station">wind station</String>
>          <String Name="Agency" Discrete="true">0</String>
>          <String Name="Station ID">1234</String>
>        </Group>
>        <Group Name="Latitude">
>          <String Name="Degree">0</String>
>          <String Name="Minutes">0</String>
>          <String Name="Seconds">0</String>
>          <String Name="Directions" Discrete="true">0</String>
>        </Group>
>        <Group Name="Longitude">
>          <String Name="Degree">0</String>
>          <String Name="Minutes">0</String>
>          <String Name="Seconds">0</String>
>          <String Name="Directions" Discrete="true">0</String>
>        </Group>
>        <String Name="Description">
>          <UnsetVal />
>        </String>
>      </Items>
>    </Att>
> 
> 
> Thank you!
> 
> Indu
> 
> -----Original Message-----
> From: David Thompson [mailto:david.thompson at kitware.com] 
> Sent: Thursday, June 25, 2015 5:31 PM
> To: Shukla, Indu ERDC-RDE-ITL-MS
> Cc: Yumin Yuan; smtk-developers at smtk.org; Hines, Amanda M ERDC-RDE-ITL-MS
> Subject: Re: [Smtk-developers] Help
> 
> Hi Indu,
> 
>> ...
>> att = asys.findAttribute('Globals’)
>> gr = att.findString('ProjectName')
>> gr = att.findGroup('ProjectInformation')
>> gr.find('ProjectName')
>> 
>> Please let me know how can I access the value of my ProjectName.
> 
> The issue is that the "find" methods return a Python object that corresponds to the base "Item" type (which does not have methods to fetch data since no data format is specified in base class). The base Item must be converted to one of the proper type (StringItem in this case), which is done with smtk.attribute.to_concrete(). Either of these should work:
> 
> 1. Fetch each item in the hierarchy
> 
>    att = asys.findAttribute('Globals')
>    gr = att.findGroup('ProjectInformation')
>    nm = smtk.attribute.to_concrete(gr.find('ProjectName'))
>    print nm.value(0)
> 
> 2. If you have a *really* recent SMTK (fetched within the last few days), you can do this:
> 
>    att = asys.findAttribute('Globals')
>    nm = smtk.attribute.to_concrete(
>      att.itemAtPath('ProjectInformation/ProjectName', '/'))
>    print nm.value(0)
> 
> where the '/' argument to "itemAtPath" is a separator character that divides the first argument into the list of items to descend.
> 
> There appears to be a bug in the variant of att.find() that takes a smtk.attribute.SearchStyle as its second argument or there would be a third way. Hopefully one of the above will work for you until it is fixed.
> 
> 	David

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.sbi
Type: application/octet-stream
Size: 49858 bytes
Desc: test.sbi
URL: <http://public.kitware.com/pipermail/smtk-developers/attachments/20150626/cf19d881/attachment-0001.obj>


More information about the Smtk-developers mailing list