Bob,

Your first suggestion cleared up my atomIndex problem. You explained {*}[0]
to me once before, and it did not sink in. Now I see that it's exactly what
needed. It's atomno = max. Is that correct?

Your second suggestion is really slick, and I learned a lot picking it
apart. Unfortunately, it leads to linear chain growth from time to time, and
that starts getting into problems. Ethane growth seems to be linear
consistently - i.e. C-C-C. If you build off of C2, you start to add
superimposed atoms, as per your Jmol math.

The _atomPick X+0, Y+.1, Z+.1 that I used seems to do two things: 1) the
atoms are close enough to bond; 2) the atoms are offset enough for minimize
to push the new atom away.

The atom substitution approach is the best way to grow the chain, but I
wanted to have an addition option to mimic standard drawing programs. Your
original suggestion clears up my problem.

Question: Is double click measure a possibility here? Specifically, are the
positions of double click 1 and double click 2 stored for use so that the
new atom could be plopped at double click 2 position (on background)? I
don't use Spartan, but that approach to addition would just about match Chem
Office Chem3d.

Otis



On Tue, Mar 23, 2010 at 7:53 AM, Robert Hanson <[email protected]> wrote:

> Right, that makes sense. When you delete atoms, Jmol does not actually
> remove them. It just marks them as "deleted". This is to save time and lower
> the chance of all sorts of problems later. So your value for "i" will be
> off. You need this:
>
> select atomIndex=_atomPicked;
> flash
>
> var x = {atomIndex=_atomPicked}.atomX;
> var y = {atomIndex=_atomPicked}.atomY+.1;
> var z = {atomIndex=_atomPicked}.atomZ+.1;
> set appendNew false;
> var w = '1\ntest\nC ' + x + ' ' + y + ' ' + z + '\n';
>  print "A " + {*}.length + " " + _atomPicked
> data 'append @w';
> print "B " + {*}.length + " " + _atomPicked + {atomIndex=_atomPicked}
> var i = {*}[0].atomIndex
>
> connect (atomIndex=_atomPicked) (atomIndex=i) single;
>
> You might consider a different way to add that atom position:
>
> var a = {atomIndex=_atomPicked};
> select a
> flash
> var pt = a.xyz * 2 - {connected(a)}.xyz
> set appendNew false;
> var w = '1\ntest\nC ' + pt.x + ' ' + pt.y + ' ' + pt.z + '\n';
> data 'append @w';
> var b = {*}[0]
> connect @a @b single;
>
>
> On Mon, Mar 22, 2010 at 11:29 PM, Otis Rothenberger <[email protected]>wrote:
>
>> Bob,
>>
>> I am having an atom index problem building a carbon chain. I set the stage
>> for this with the following script:
>>
>> delete hydrogens;echo Clicked atoms will|ADD a carbon atom.;
>>
>> If at this point I check atomIndexes, and they are A-OK. The hydrogens are
>> gone, and the atomIndexes run from 0 to the new number of atoms -1.
>>
>> The carbon atom click/add then uses the following script:
>>
>> select atomIndex=_atomPicked;flash;var i = {*}.atomIndex.max + 1;var j = i
>> + 1;var x = {atomIndex=_atomPicked}.atomX;var y =
>> {atomIndex=_atomPicked}.atomY+.1;var z =
>> {atomIndex=_atomPicked}.atomZ+.1;set appendNew false;var w = '1\ntest\nC ' +
>> x + ' ' + y + ' ' + z + '\n';data 'append @w';connect
>> (atomIndex=_atomPicked) (atomIndex=i) single;
>>
>> Flash is my own command that simply substitutes the Jmol script to flash
>> the atom magenta for .5 seconds prior to jmolScript()
>>
>> If I do NOT delete the hydrogens (step 1 above), then the script works
>> nicely. If I do delete the hydrogens (step 1 again) the first click/add
>> fails to bond -
>>
>>  i.e. connect (atomIndex=_atomPicked) (atomIndex=i) single
>>
>> is failing. The new carbon atom is added, but it floats away without
>> connecting on a subsequent minimize. After this first failure, the script
>> works on subsequent clicks.
>>
>> I could simply leave the hydrogens on, but I'm trying to give the editor
>> the feel of standard editors that build C frameworks.
>>
>> The working page is here:
>>
>> http://chemagic.com/web_molecules/script_page_large.aspx
>>
>> Click Display Control Panel.
>>
>> The page is set to do the with-hydrogen edit (works). If you do a delete
>> hydrogens in the text command field, you will see the problem on the first C
>> add.
>>
>> Any thoughts on the problem? It appears for the first click atomIndex=i is
>> not what I think it is??
>>
>> Otis
>>
>> --
>> Otis Rothenberger
>> http://chemagic.org
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Jmol-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>
>>
>
>
> --
> Robert M. Hanson
> Professor of Chemistry
> St. Olaf College
> 1520 St. Olaf Ave.
> Northfield, MN 55057
> http://www.stolaf.edu/people/hansonr
> phone: 507-786-3107
>
>
> If nature does not answer first what we want,
> it is better to take what answer we get.
>
> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
>
> _______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>


-- 
Otis Rothenberger
http://chemagic.org
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to