On Tue, Jun 8, 2010 at 12:06 AM, Rob Soe <kym3p...@gmail.com> wrote:
> Hi,
> Thanks a lot for the suggestions.
>
> I have this plan that I am trying to work out. I am planning to use
> OBSetData() and use SetAttribute() to set a string (converted from a float
> number that I want to associate the molecule with).
>
> Here is the code:
>
> //Float to String conversion
>   ostringstream buffer;
>     double temp=0.987;
>     buffer << temp;
>     string strTemp = buffer.str();
> //End
>
> //Storing data using OBSetData()
>     OBSetData *sim = new OBSetData();
>     sim->SetAttribute(strTemp.c_str());
>     mol.SetData(sim);
> //End
>
> So now the 'mol' should have the attribute data?

Yes, but the attribute is the name for your data. SetValue and
GetValue should be used for setting the temperature.

sim->SettAttribute("temp");
sim->SetValue(strTemp.c_str())
mol.SetData(sim)

To retrieve:

OBSetData *data = mol.GetData("temp");

Tim

> I am not sure how I can access such attribute data. I tried to use
> mol.getData() but it seems not working.
>
> Thanks!
> Rob
>
> On Mon, Jun 7, 2010 at 2:48 PM, Geoffrey Hutchison
> <ge...@geoffhutchison.net> wrote:
>>
>> > You need create an OBPairData (a subclass of OBGenericData), and apply
>> > it to the molecule using OBMol.SetData. I usually grep the OpenBabel
>> > source for examples of things.
>>
>> There are also working examples in the API documentation, e.g. (see the
>> Detailed Description):
>>
>> http://openbabel.org/api/2.2.0/classOpenBabel_1_1OBGenericData.shtml
>>
>> Cheers,
>> -Geoff
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> OpenBabel-discuss mailing list
> OpenBabel-discuss@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
>
>

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to