You can use a modified version of the linked solution. In the linked solution you have
\renewcommand*\othersectionlevelsformat[1]{%
\makebox[0pt][r]{%
\csname the#1\endcsname
\enskip
}%
}
This puts the sectioning number in a box of zero width aligned to the right which is why the number sticks into the margin. The \enskip ensures a distance of 1en between number and heading. It is flawed, though. As the KOMA-Script manual describes \othersectionlevelsformat has three arguments and the 3rd is the corresponding \the<counter. A better definition would be
\renewcommand*\othersectionlevelsformat[3]{%
\makebox[0pt][r]{#3\enskip}%
}
Now that the definition is corrected we can adjust it. In order to have the numbers horizontally centered to each other you could put a second box into the first with a certain given width (1.5cm, say) and have the contents centered:
\renewcommand*\othersectionlevelsformat[3]{%
\makebox[0pt][r]{\makebox[1.5cm][c]{#3\autodot}}%
}

\documentclass{scrartcl}
\renewcommand*\othersectionlevelsformat[3]{%
\makebox[0pt][r]{\makebox[1.5cm][c]{#3\autodot}}%
}
\usepackage{blindtext}
\begin{document}
\blinddocument
\end{document}
Adjusting this to scrbook and chapters is easy: we just need a corresponding definition for \chapterformat. This command has no arguments and we use \thechapter for placing the number.
\documentclass{scrbook}
\newcommand*\marginnumber[1]{\makebox[0pt][r]{\makebox[1.5cm][c]{#1}}}
\renewcommand*\chapterformat{\marginnumber{\thechapter\autodot}}
\renewcommand*\othersectionlevelsformat[3]{\marginnumber{#3\autodot}}
\usepackage{blindtext}
\begin{document}
\blinddocument
\end{document}
scrartclclass o another. – Aradnix Aug 19 '14 at 06:19amsbookclass andKOMAare very different classes/packages. – Aug 19 '14 at 06:35At least on pages with an odd page number the section numbers seem to be placed in the margin.
– Christopher Aug 19 '14 at 06:53