61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
# NX Version:NX 2412
|
|
# Email:809262979@qq.com
|
|
# python .py created by JackLee
|
|
# NX run .py alt+F8
|
|
|
|
import NXOpen
|
|
import NXOpen.CAM
|
|
import NXOpen.UF as UF
|
|
import inspect
|
|
import io
|
|
|
|
from contextlib import redirect_stdout
|
|
# 获取当前会话
|
|
session = NXOpen.Session.GetSession()
|
|
# 打开列表窗口用于输出信息
|
|
lw = session.ListingWindow
|
|
lw.Open()
|
|
|
|
# 定义要检查的模块列表,具体要检查的模块自行设定,不建议设置太多模块同时导出,会卡死你的!
|
|
modules = [NXOpen]
|
|
|
|
#输出代码缩进级别
|
|
def print_with_indent(indent_level):
|
|
indent = " " * indent_level
|
|
return indent
|
|
|
|
def print_with(cls_name,head_str,indent_level):
|
|
if not cls_name.startswith('__') and not cls_name.startswith('_'):
|
|
lw.WriteLine(f"{print_with_indent(indent_level)}{head_str}:{cls_name}")
|
|
def main():
|
|
for module in modules:
|
|
lw.WriteLine(f"module name:{module.__name__}")
|
|
classes = inspect.getmembers(module)
|
|
for cls_name,cls in classes:
|
|
print_with(cls_name,"class",1)
|
|
subs = inspect.getmembers(cls)
|
|
for sub_name,sub in subs:
|
|
if inspect.isclass(sub):
|
|
print_with(sub_name,"class",2)
|
|
attrs=inspect.getmembers(sub)
|
|
for attr_name,attr in attrs:
|
|
if attr_name not in ('ValueOf', 'mro'):
|
|
print_with(attr_name,"attribute",3)
|
|
elif inspect.ismethoddescriptor(sub):
|
|
print_with(sub_name,"method",2)
|
|
#lw.WriteLine(f"{sub}")
|
|
else:
|
|
print_with(sub_name,"attribute",2)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
#"----------该脚本屏蔽内容如下:-----------"
|
|
#"__"
|
|
#"_"
|
|
#"method_descriptor"
|
|
#"getset_descriptor"
|
|
#f"builtin_function_or_method"
|
|
#"-------------------------------------"
|
|
#"屏蔽以上内容方便API的阅读,被屏蔽掉的内容作者认为是python内置或者绑定函数,对象,成员.阅读意义不大"
|
|
main() |