Code Monkey home page Code Monkey logo

freecad_mod_dev_guide's Issues

Type system clarification

Regarding this chapter: https://github.com/qingfengxia/FreeCAD_Mod_Dev_Guide/blob/master/chapters/3.FreeCAD_Base_App_modules.md#type-baseclass-pyobjectbase

Instead of listing the code, it would be more useful to document the purpose of the type system and how it's being used.

See my investigation here:
FreeCAD/FreeCAD#3802 (comment)

I think the main reason for this is serialization and code inspection. So that document object instances can be created from strings stored in a FCStd file, and object instances be inspected in a Python console. And more importantly, to decouple C++ implementation from the UI appearance (Property and type names in a view toolbar).

I don't think it has anything to do with reference counting, outside the PyObject exports, does it?

A more practical use case is the TypeId and addObject implementation. Using addObject from Python you can create instances of C++ classes and map them to the Python type system.

As most of workbenches are developed in Python nowadays, there should be some recommendation on how to identify object types. E.g.:

You may use TypeId if you want to use document object properties
You must use isinstance to determine that the object has a particular method, as TypeId can be re-implemented by a different class

new module import mechanism

all third-party module can be inserted into freecad package

from pkgutil import extend_path

see example in Plot module, init

it will affect Mod folder structure

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.