Bolt and nut scripts are included in the Plant 3D supplied variants.zip under the ...\varmain\divsub\… location and can be called into any Python script as follows:
At the top of your script add the highlighted 2 lines.
# Import Python Packages
from aqa.math import *
from varmain.divsub.cbolt6_001 import *
from varmain.divsub.cnut6_001 import *
from varmain.primitiv import *
from varmain.var_basic import *
from varmain.custom import *
Then later in your script, after the metadata section and def command:
o1 = NUT_BOLT_HEAD_6_001(s, W=MW, H=MH).rotateY(90.0).translate((0.0, 0.0, 0.0))
o2 = CNUT6_001(s, D=W, W=MW, H=MH).rotateY(90.0).translate((0.0, 0.0, 0.0))
Where D = bolt diameter, W = dimension across flats, H = Bolt/nut height. They will be bottom center justified pointing up in the positive Z direction so you will likely need to rotate and translate as needed.