Though they were neighbours, the pair were not close, the court heard.
There was a chance meeting at a mutual friend's house.
Macmillan had been drinking home-brewed bourbon while the victim had one drink before returning home to put one of her children down for a nap.
At 6.30pm, the woman woke to found the man sitting on the end of her bed calling her name.
He lifted the bed covers and reached out to touch the victim, but she pushed him away.
Macmillan persisted, rubbing her leg over the sheets.
When the woman told him to leave he replied: "Come on".
The exchange prompted the 5-year-old's dash for the knife, on which Macmillan cut his hand before running from the house.
When police arrived, they found the defendant outside the victim's home in "an extremely intoxicated state".
The court heard Macmillan had no similar convictions and the woman had given him no indication she wanted his company.
Judge Phillips said the man suffered from depression, anxiety and social isolation.
The effects on the victim had been "catastrophic", the judge said, and she was particularly devastated her son had to see it all unfold.
Macmillan was sentenced to nine months' supervision, 120 hours' community work and was ordered to pay the victim $1290.