ACD/ChemBasic is a simple, convenient, and functionally rich programming language for the presentation and manipulation of molecular structure and related objects through ACD/Labs' software. ACD/ChemBasic allows you to customize ACD/Labs software for your own purposes, to automate routine tasks, or to interface your own programs with ACD/Labs software.
You can use ACD/Chem Basic to:
Because ACD/ChemBasic is a superset of Basic, it is easy to learn and easy to use; consisting of common statements and functions for dealing with numbers or texts, built-in molecular objects and functions to manipulate them, and the objects and functionality of ACD/Labs programs.
The meta-language commands consist of text that falls into one of three main categories:
This program will extract the name of the compound as a string and pass it back to the calling program.
View code
Function GetIUPAC(Diagram as Object) as String
' Returns IUPAC name for ChemSketch's molecular diagram
Dim Asm As Object
Set Asm = Assemblies.AddCSImported(Diagram)
GetIUPAC = Asm.Molecules(1).GetIUPACName
Asm.Kill
End Function
This program generates and 3D-optimizes molecules of general formula HO-(CH2)n-COOH, n=1-5
View code
Function Main As String
' Declarations
Dim n,i,ph,pw,l,t,w,h,k As Integer
' Molecular objects
Dim Ent,Mol,Struc ,Oh, Cox,O1ox,O2ox,AtomCurr,AtomPrev As Object
' Sketch objects
Dim Page,Diagram As Object
' Title for our messages
Const title="Example"
' Number of homologues
Const nmax=5
' DO SOME HOUSE-KEEPING
' Add an empty page to current document
Page=ActiveDocument.AddEmpty
' Read out the page dimensions
ph=Page.GetHeight
pw=Page.GetWidth
' IN A LOOP, GENERATE AND OPTIMIZE HOMOLOGS
For n=1 to nmax
' CREATE THE CURRENT MOLECULE
' 1. Create a new assembly
Ent=Assemblies.AddEmpty ' Ent is an assembly that holds atoms
Mol=Ent.Molecules.AddEmpty ' Mol contains valence bonds above assembly
' 2. Add OH to (now still empty) assembly
Oh=NewAtom(8) ' create isolated oxygen atom
Ent.Add(Oh) ' add it to assembly
' 3. Add COOH group
Cox=NewAtom(6) : Ent.Add(Cox)
O1ox=NewAtom(8) : Ent.Add(O1ox)
O2ox=NewAtom(8) : Ent.Add(O2ox)
' 4. Make bonds in that carboxy group
Mol.AddBond(Cox,O1ox,2) : Mol.AddBond(Cox,O2ox,1) :AtomPrev=Oh
' 5. Finally, add polymethelene chain (CH2)n atoms & bonds
For i=1 To n
AtomCurr=NewAtom(6)
Mol.AddBond(AtomCurr,AtomPrev,1)
AtomPrev=AtomCurr
Next i
Mol.AddBond(AtomPrev,Cox,1)
' MOLECULE IS READY. OPTIMIZE IT
' TO GRADIENT NORM OF 0.1
' AND GET THE RESULTING STRUCTURE
Struc=Mol.Do3DOptimize(0.1)
' DEPICT THE RESULT AS A
' CHEMSKETCH DIAGRAM
' Draw
Diagram=Page.Diagrams.AddEmpty
Diagram.Depict(Struc)
' Adjust the position
Diagram.GetBound(l,t,w,h)
l=Int(pw/3)
t=200+(n-1)*Int(ph/(nmax+1))
Diagram.SetBound(l,t,w,h)
Next n
' That's all!
Main="Demo completed"
End Function
For your convenience we have scripted a number of functions in ChemBasic (‘Goodies’) following specific requests from customers. A number of these are available within ChemSketch (as button functions) when you install ChemBasic. To access these, in the Structure window, from the Options menu, choose ChemBasic Organizer.