# Python 3
import common
import sys
sys.path.append(r"C:\Program Files (x86)\PerkinElmerInformatics\ChemOffice2016\ChemScript\Lib")
import ChemScript16 as cs

mol = cs.StructureData.LoadData("c1ccccc1")
op = cs.NormOptions()

op.AnonList = False
op.Azide = False
op.CleaveIntoSalts = False
op.CreatedDelRep_1 = False
op.CreatedDelRep_2 = False
op.CollapseZwitterion = False
op.Dative = False
op.DativeToDouble = False
op.Dekekulize = True
op.Delrep = False
op.Diazo_a = False
op.Diazo_b = False
op.FeaturelessHydrogens = False
op.Isonitrile_fg = False
op.MergeCharges = False
op.MergeMetalSalts = False
op.MoveChargeFromCarbon = False
op.NeutralDiazo_fg = False
op.RemoveIsotopy = False
op.RemoveLabel = False
op.RemoveNonGraphStereo = False
op.RemoveRTable = False
op.RemoveRxnCenters = False
op.RemoveTextAtoms = False
op.RemoveValence = False
op.RemoveWedge = False
op.StripEitherDoubleBond = False
op.StripEitherSingleBond = False
op.R3NO_b = False
op.ProvideMissingCoords = False
op.Thiazole = False
op.XMinusToX_fg = False
op.ExpandStoichiometry = False
op.ConsolidateStoichiometry = False

print(op) # Prints out the values of the options

class MyHydrogenCounter(common.HydrogenCounter):
    def getoutput(self, smi):
        mol = cs.StructureData.LoadData(smi)
        if mol is None:
            return None, "Parse_error"
        mol.NormalizeStructure(op)
        writer = cs.SDFileWriter.OpenFile("tmp.sdf", cs.OverWrite)
        writer = cs.SDFileWriter.OpenFile("tmp.sdf", cs.OverWrite)
        writer.WriteStructure(mol)
        writer.Close()
        with open("tmp.sdf", "r") as f:
            molfile = f.read()
        return None, "MOLFILE:%s" % molfile.replace("\n", "!!")

if __name__ == "__main__":
    myname = "ChemDraw_16.0"
    # MyHydrogenCounter(myname).main()

@@ -162,53 +162,8 @@
 %0D%0A%0D%0A
-mol = cs.StructureData.LoadData(%22c1ccccc1%22)%0D%0A
 op =
@@ -1336,24 +1336,29 @@
 or%22%0D%0A       
+ ok =
  mol.Normali
@@ -1386,332 +1386,440 @@
     
-writer = cs.SDFileWriter.OpenFile(%22tmp.sdf%22, cs.OverWrite)%0D%0A        writer = cs.SDFileWriter.OpenFile(%22tmp.sdf%22, cs.OverWrite)%0D%0A        writer.WriteStructure(mol)%0D%0A        writer.Close()%0D%0A        with open(%22tmp.sdf%22, %22r%22) as f:%0D%0A            molfile = f.read()%0D%0A        return None, %22MOLFILE:%25s%22 %25 molfile.replace(%22%5Cn%22, %22!!%22)
+if not ok:%0D%0A            # never happens - warning to stdout but I can't capture it%0D%0A            return None, %22Kekulization error%22%0D%0A        mol.ConvertTo3DStructure() # adds hydrogens by default%0D%0A        numHs = %5B%5D%0D%0A        for atom in mol.Atoms:%0D%0A            if atom.Element != %22H%22:%0D%0A                numH = sum(%5B1 for x in mol.BondedAtomsOf(atom) if x.Element == %22H%22%5D)%0D%0A                numHs.append(numH)%0D%0A        return numHs, None
 %0D%0A%0D%0A
@@ -1876,21 +1876,19 @@
 _16.0%22%0D%0A
+
    
- #
  MyHydro

Update ChemDraw script to directly count the number of hydrogens rather than relying on the incorrect MOL file output.