Using parts library JSON (PLJSON) files¶
Now that we have a proper PLJSON file, what can we do with it?
Create library CAD files¶
The generate()
function of the party.library_use
module will create ccad scripts and CAD files
(depending on the optional arguments values) in subfolders of
the folder containing the parts library JSON (PLJSON) file.
Formats¶
From the parts library JSON (PLJSON) file, it is possible to create one CAD file per entry in the data section of the PLJSON file in the following formats:
- STEP (AP203)
- STL
- HTML (to view the part in the browser using X3DOM)
Example¶
See the examples/ISO_4014/use_library_json.py
script for an example of
how to generate the CAD files from the parts library (PLJSON) file.
#!/usr/bin/python
# coding: utf-8
r"""Example use of the library.json file to create geometry_scripts and
cad files
"""
import logging
from os.path import join, dirname
from party.library_use import generate
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s :: %(levelname)6s :: '
'%(module)20s :: %(lineno)3d :: %(message)s')
generate(json_library_filepath=join(dirname(__file__), "library.json"),
generate_steps=True,
generate_stls=True,
generate_htmls=True,
generate_svgs=True)
Create the library documentation¶
The generate()
function of the party.library_documentation
module will create HTML documentation of the parts library JSON (PLJSON) file in the folder passed as a parameter.
Formats¶
Currently, only HTML documentation generation is implemented.
Example¶
See the examples/create_documentation_example.py
script for an example of
how to generate the documentation of the parts library (PLJSON) file.
#!/usr/bin/python
# coding: utf-8
r"""Parts library documentation creation example"""
from os.path import dirname, join
import logging
from party.library_documentation import create_libraries_sphinx_sources
def main():
r"""Main function for the parts library documentation example"""
create_libraries_sphinx_sources(join(dirname(__file__), "../examples"),
join(dirname(__file__), "../examples/doc"))
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s :: %(levelname)6s :: '
'%(module)20s :: %(lineno)3d :: %(message)s')
main()
Use the parts in other projects¶
Work in progress to use the parts library JSON (PLJSON) files in:
- a new (in development) CAD project definition structure based on acyclic directed graphs.
- other CAD softwares that offer scripting/plugin capabilities