Amazing 'built-in' FC/Sketcher Capability - Try to understand 'mechanism' Copying Sketch recognising edge.Tag !?

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Posts: 2044
Joined: Wed May 04, 2016 3:58 pm

Amazing 'built-in' FC/Sketcher Capability - Try to understand 'mechanism' Copying Sketch recognising edge.Tag !?

Postby paullee » Sat Jul 06, 2019 9:01 am

Not sure this should just go into Python Script or Here, just feel free to move if found better elsewhere!

I am learning / experimenting with SketchObjectPython. After testing following steps, I am amazed by what FC / Sketcher do without me writing any codes for it - just wonder what supposed to happen and understand FC / Sketcher's behaviour without having to learn C++ etc. to read FC code :lol:

Preparation - No.1 - 2 screencaptures below
  1. I make 2 SketchObjectPython
  2. 1st (ArchSketch_Master) with a Rectangle
  3. 2nd (ArchSketch_Dependent) has No geometry
  4. 2nd SketchObjectPython has 2 properties

    Code: Select all

          fp.addProperty("App::PropertyStringList","MasterSketchEdgeGroupsAndEdges","ArchSketch Properties","MasterSketch's Edges ")
          obj.addProperty("App::PropertyLink","MasterSketch","Referenced Sketches ","Master Sketch")
  5. In the PropertyStringList, I copy in Tag of 2 edges in 1st object (ArchSketch_Master)
  6. In the PropertyLink, it is linked to the 1st object (ArchSketch_Dependent)
Copying Sketches - No.3 screencaptures below
  1. Now, I select the 1st object (ArchSketch_Dependent) ... press Ctrl-C to copy
  2. FC ask if I want to copy the dependency...(the 1st ArchSketch_Master)
  3. Answer yes, supposedly FC would copy the both SketchObjectPython ...
Amazing Result FC 'tracing' edge.Tag information!? - No.4 screencaptures below
  1. Not only a copy of both Objects ... it also make the Copy of 'ArchSketch_Dependent' PropertyLink point to the Copy of 'ArchSketch_Master.'.. that's terrific!
  2. ... But MORE! In the Copy of 'ArchSketch_Dependent' PropertyStringList - just thought these string of tags are 'meaningless' to FC - FC 'update' these tags by replacing with the corresponding edges' tag in the 'Copy' of ArchSketch_Master. The 'new' tags are different! . :o
Just wonder If I mistake myself with observations above? Or I miss something simple? Hope to understand more how FC works here.

Attached the file with simply the 2 SketchObjectPython for testing.

Thanks in advance.

Maybe @abdullah can give some quick insight? :)
abdullah wrote: Ping
Screenshot from 2019-07-06 16-12-20.png
Screenshot from 2019-07-06 16-12-20.png (170.36 KiB) Viewed 146 times
Screenshot from 2019-07-06 16-12-02.png
Screenshot from 2019-07-06 16-12-02.png (171.72 KiB) Viewed 146 times
Screenshot from 2019-07-06 16-13-12.png
Screenshot from 2019-07-06 16-13-12.png (214.84 KiB) Viewed 146 times
Screenshot from 2019-07-06 16-13-50.png
Screenshot from 2019-07-06 16-13-50.png (248.65 KiB) Viewed 146 times
Test_ Sketcher_ Copy Edge Tag Issue.FCStd
(6.99 KiB) Downloaded 3 times