MolDraw.Core 0.4.0

dotnet add package MolDraw.Core --version 0.4.0
                    
NuGet\Install-Package MolDraw.Core -Version 0.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MolDraw.Core" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MolDraw.Core" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="MolDraw.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MolDraw.Core --version 0.4.0
                    
#r "nuget: MolDraw.Core, 0.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MolDraw.Core@0.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MolDraw.Core&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=MolDraw.Core&version=0.4.0
                    
Install as a Cake Tool

MolDraw.Core

NuGet Downloads License: Apache-2.0

The chemistry engine for MolDraw.Net. Parses SMILES, MOL and SDF input with NCDK and turns it into a clean, toolkit-neutral MoleculeDepiction: 2D layout, aromaticity perception, ring-aware double bonds, wedge/hash stereo, implicit hydrogens and RDKit-compatible heavy-atom order — so per-atom model output lines up with the picture.

Install

dotnet add package MolDraw.Core

Targets net11.0. Pulls in MolDraw.Depiction and NCDK.

Quick start: .NET MAUI

// MauiProgram.cs
using MolDraw.Core;

builder.UseMauiApp<App>()
       .UseMolDraw();                 // renderer + depiction cache (package MolDraw.Maui)
builder.Services.AddMolDrawCore();    // the NCDK chemistry engine
<md:MoleculeView Smiles="{Binding Smiles}" AtomWeights="{Binding AtomWeights}" />

Smiles now yields a picture. Without AddMolDrawCore() (or another IChemistryEngine) MoleculeView.Smiles only reports an ErrorMessage.

Quick start: without MAUI (console, server, tests)

using MolDraw.Core.Ncdk;      // MoleculeLoader / DepictionBuilder – the NCDK-backed API
using MolDraw.Depiction;      // MoleculeDepiction – the toolkit-neutral model

var loader = new MoleculeLoader();
var builder = new DepictionBuilder();

var molecule = loader.ParseSmiles("c1ccccc1O");          // phenol (throws MoleculeParseException on bad input)
MoleculeDepiction depiction = builder.Build(molecule);

// also available: TryParseSmiles(...), Load(stream, MoleculeFormat.MolFile | Sdf | Smiles), LoadAll(...)

Rendering is not part of this package — pair it with MolDraw.Skia:

File.WriteAllBytes("phenol.png", new MoleculeImageExporter().RenderPng(depiction, 400, 300));

What registering does

AddMolDrawCore() adds three singletons with TryAddSingleton, so anything you registered before it wins:

Service Implementation
IChemistryEngine NcdkDepictionEngine (Name = "NCDK") — this is what MoleculeView.Smiles calls
IMoleculeLoader MoleculeLoader (ParseSmiles, TryParseSmiles, Load, LoadAll)
IDepictionBuilder DepictionBuilder (Build(molecule, options))
// Register your own engine first and NCDK stays out of the picture entirely:
builder.Services.AddSingleton<IChemistryEngine, MyEngine>();
builder.Services.AddMolDrawCore();

API

Member Notes
MoleculeLoader.ParseSmiles(string) Atom order = order of heavy atoms in the SMILES (= RDKit MolFromSmiles). [H] is folded into implicit counts like RDKit's RemoveHs
MoleculeLoader.TryParseSmiles(string?, out IAtomContainer?, out string?) Non-throwing variant for UI input
MoleculeLoader.Load(Stream, MoleculeFormat) / LoadAll(...) First molecule / all records (SDF, SMILES lines, single molfile)
DepictionBuilder.Build(IAtomContainer, DepictionBuildOptions?) Never mutates the input; atom i of the depiction == molecule.Atoms[i]
MoleculeLoaderOptions KeepExplicitHydrogens, MoleculeFormat, … (MolDraw.Core.Ncdk)
DepictionBuildOptions ForceLayout, PerceiveAromaticity, AssignMissingWedges, CarbonLabels (MolDraw.Depiction)

Depictions and services are immutable/stateless and thread-safe; MoleculeView runs parsing + layout off the UI thread.

License note

MolDraw.Core depends on NCDK 1.6.1 (LGPL-2.1-only) as a separate NuGet package; NCDK is not modified and not statically linked. Apps that distribute MolDraw.Core must satisfy the LGPL (ship the NCDK licence text, point to its source, allow replacing NCDK.dll). The other MolDraw.Net packages — MolDraw.Depiction, MolDraw.Skia and MolDraw.Maui — do not depend on NCDK, so you can keep an app LGPL-free by supplying your own IChemistryEngine. Details: THIRD-PARTY-NOTICES.md.

Known NCDK quirks (not trim-safe, InChI natives missing on ARM64) are listed in the main README; MolDraw never calls InChI.

Package Purpose
MolDraw.Depiction model + IChemistryEngine seam
MolDraw.Core this package — NCDK engine
MolDraw.Skia SkiaSharp renderer, PNG/SVG export
MolDraw.Maui .NET MAUI MoleculeView control

Documentation

License

Apache-2.0 © Agredo Application. NCDK: LGPL-2.1-only.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.0 56 11/18/2026
0.3.0 52 11/17/2026