question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Component Copy (CAD Instances)

See original GitHub issue

Change directly flows on from discussion: #90 (also relates closely to #96)

The target is for the following code-fragments to evaluate as they’re shown

Implicit Part behaviour

>>> c1 = Cube(size=10)
>>> c2 = Cube(size=10)
>>> c1.local_obj is c2.local_obj
False
>>> c1 == c2
True
>>> hash(c1) == hash(c2)
True
>>> c1.local_obj = c1.local_obj.faces('>Z').hole(1)
>>> c1 == c2
False
  • done

Explicit cqpart.Part instance modifier

>>> from copy import copy
>>> c1 = Cube(size=10)
>>> c2 = copy(c1)
>>> c1.local_obj is c2.local_obj
True
>>> c1.local_obj = c1.local_obj.faces('>Z').hole(1)
>>> # OR
>>> #c2.local_obj = c2.local_obj.faces('>Z').hole(1)
>>> c1.local_obj is c2.local_obj
True
  • done
>>> c1 = Cube(size=10)
>>> c2 = copy(c1)
>>> c1.world_coords = CoordSystem(origin=(10,0,0))
>>> c2.world_coords = CoordSystem(origin=(-10,0,0))
>>> c1.world_obj = c1.world_obj.faces('>X').hole(1)
>>> c2.world_obj = c2.world_obj.faces('>Y').hole(1)
>>> c1.local_obj is c2.local_obj
True
>>> c1.world_obj is c2.world_obj  # would never be True
False
>>> display(c1.local_obj)  # cube
>>> display(c2.local_obj)  # cube
>>> display(c1.world_obj)  # cube with hole along X axis
>>> display(c2.world_obj)  # cube with hole along Y axis
  • done

Documentation

PR

  • ping @gntech @zignig @dcowden @zwn for review

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
gntechcommented, Jun 5, 2018

I dont understand the workings of cqparts fully but what would be wrong with this:

What if c1 = Cube() only creates the local obj and c1 is then wrapped in a = WorldPart(c1) class that has the woorld coordinates and makes a world obj from the local obj? b = copy(a) would have the same reference to c1 but its own world coordinates and own world_obj.

Cube() only creates the actual geometry. WorldPart() wrapps a geometry and define world coordinates.

1reaction
gntechcommented, May 26, 2018

On second thought, I agree as well, keep it as pythonic as possible

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I make all the instances of a part in an assembly the ...
Solved: I've created an assembly using the same parts, but added them at different times as I created it. Inventor creates a new...
Read more >
Copy and Paste Sketches, Bodies, and Components in Fusion ...
Components can be pasted within the same file as linked instances or new copies. They can also be pasted into another design file...
Read more >
Part SimpleCopy - FreeCAD Documentation
Select an object for which you wish to make a copy. Go to the menu Part → Create a copy → Part SimpleCopy.svg...
Read more >
Create and insert component instances - Figma Help Center
Create instances · A. Duplicate using the keyboard shortcut. Mac: ⌘ Command D Windows: Ctrl + D · B Drag to copy. Hold...
Read more >
Reuse Mates - SOLIDWORKS CAD - GoEngineer Community
You most likely need to use the Copy with Mates option. It's found under the dropdown for insert components. You'll be prompted to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found