STEP file read might be crazy long ...

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: STEP file read might be crazy long ...

Post by sgrogan »

vejmarie wrote:Which commit is your build using ? Probably not the latest one (sgrogan is going to "kick me")
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9842 +15 (Git)
Build type: Release
Branch: step
Hash: 304a2622474311d990a3fe99be233e78af612d4f
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
No worries, what is the best to build, the HEAD of step on your fork? It's trivial to do the test builds, now that I have built your OCCT patch.
"fight the good fight"
User avatar
NormandC
Veteran
Posts: 18589
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: STEP file read might be crazy long ...

Post by NormandC »

easyw-fc wrote:
ickby wrote:just call the addObject() function or add the object to the Group property manually.
something like that?
(image)
but with groups is it possible to assign placement to all the group's parts?
Groups are just a container without a placement, aren't they?

Maurice
ickby was not talking about Groups, which have been in FreeCAD for a long time, but about the Part container introduced in 0.17 with PartDesignNext. It seems that the Part container has a "Group" property. It also has a placement.
FC017_Part_View_Properties_01.png
FC017_Part_View_Properties_01.png (25.07 KiB) Viewed 2823 times
Then again maybe he's talking about a different thing.

O/T: the Part container has the same icon as Group, this will need to be addressed at some point to avoid confusion...
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: STEP file read might be crazy long ...

Post by ickby »

Normand is right, i'm talking about App::Part. In the GUI it is currently only accessible from PartDesign, but it is a General object which represents a local coordinate System.
User avatar
vejmarie
Posts: 713
Joined: Mon Jan 04, 2016 4:52 pm
Location: Somewhere between France, USA and Taiwan
Contact:

Re: STEP file read might be crazy long ...

Post by vejmarie »

sgrogan wrote:
vejmarie wrote:Which commit is your build using ? Probably not the latest one (sgrogan is going to "kick me")
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9842 +15 (Git)
Build type: Release
Branch: step
Hash: 304a2622474311d990a3fe99be233e78af612d4f
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
No worries, what is the best to build, the HEAD of step on your fork? It's trivial to do the test builds, now that I have built your OCCT patch.
Yep the HEAD of my step branch is the code to build. I'll be curious to have @easyw-fc testing the latest patch and publishing new results. I am pretty sure that it fixed the long read time ;)
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: STEP file read might be crazy long ...

Post by easyw-fc »

NormandC wrote: ickby was not talking about Groups, which have been in FreeCAD for a long time, but about the Part container introduced in 0.17 with PartDesignNext. It seems that the Part container has a "Group" property. It also has a placement.
thx that is interesting
NormandC wrote: O/T: the Part container has the same icon as Group, this will need to be addressed at some point to avoid confusion...
+1
may be @agrison may find some nice ico
agryson wrote: - Aligns Workbenchs to guidelines
ickby wrote:Normand is right, i'm talking about App::Part. In the GUI it is currently only accessible from PartDesign, but it is a General object which represents a local coordinate System.
is it possible to create a hierarchy of App::Part?
It seems there is some issue with Axis when manual assembling subParts
part-hierarchy.png
part-hierarchy.png (158.87 KiB) Viewed 2792 times
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: STEP file read might be crazy long ...

Post by ickby »

is it possible to create a hierarchy of App::Part?
It seems there is some issue with Axis when manual assembling subParts
I'm curerntly working on fixing some bugs that are in stacking parts, should work soon.
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: STEP file read might be crazy long ...

Post by wmayer »

ickby wrote:It should not crash :) The moving should actually work, but again, still working on it. It is rather rough at the moment. However, as you are working on this now it may be good to use the Parts to not need to make the switch later.
In debug mode I always get a crash here, too. Looking at the code it became clear very quickly:
it crashes at this line: https://github.com/FreeCAD/FreeCAD/comm ... 40e832R125

And the reason is that you cannot iterate over a vector and modify its size at the same time. As soon as the insert method enlarges the array all iterators become invalid and still using them leads to undefined behaviour. See also: http://www.cplusplus.com/reference/vect ... or/insert/

git commit 5d21eb6 fixes the crash. However, the method still suffers from a second problem: in case the graph is not a DAG then it may run into an infinite loop.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: STEP file read might be crazy long ...

Post by easyw-fc »

ickby wrote: I'm curerntly working on fixing some bugs that are in stacking parts, should work soon.
thx
ATM I can assembly root Parts and leafs with python and apply a placement to roots
EDIT
is it possible to create a simple copy of the all Part assembly? (also may be with a python macro?)

assembly-parts.FCStd
(5.85 KiB) Downloaded 61 times

Code: Select all

# -*- coding: utf-8 -*-

import FreeCAD,Part
import PartDesignGui

#doc = FreeCADGui.ActiveDocument
doc = FreeCAD.newDocument()

#Gui.activateWorkbench("PartDesignWorkbench")
App.activeDocument().Tip = App.activeDocument().addObject('App::Part','rootPart')
#root_part = App.activeDocument().getObject('App::Part')
root_part = App.activeDocument().rootPart
App.activeDocument().rootPart.Label = 'rootPart'
Gui.activeView().setActiveObject('part', App.activeDocument().rootPart)
#root_part=FreeCAD.ActiveDocument.ActiveObject
App.ActiveDocument.recompute()
App.ActiveDocument.addObject("Part::Box","Cube_leaf")
App.ActiveDocument.ActiveObject.Label = "Cube_leaf"
App.ActiveDocument.recompute()
leaf_part=FreeCAD.ActiveDocument.ActiveObject
FreeCADGui.ActiveDocument.getObject("Cube_leaf").ShapeColor = (1.00,0.00,0.00)
Gui.SendMsgToActiveView("ViewFit")
#grp=doc.addObject("App::DocumentObjectGroup", "Board_Geoms")
#grp.addObject(doc_outline)
root_part.addObject(leaf_part)

App.activeDocument().Tip = App.activeDocument().addObject('App::Part','rootPart_2')
#root_part = App.activeDocument().getObject('App::Part')
root_part_2 = App.activeDocument().rootPart_2
Gui.activeView().setActiveObject('part', App.activeDocument().rootPart)
root_part.addObject(root_part_2)
App.ActiveDocument.recompute()

App.ActiveDocument.addObject("Part::Cone","Cone_leaf")
App.ActiveDocument.ActiveObject.Label = "Cone_leaf"
App.ActiveDocument.recompute()
leaf_part_2=FreeCAD.ActiveDocument.ActiveObject
FreeCADGui.ActiveDocument.getObject("Cone_leaf").ShapeColor = (0.00,0.00,1.00)
root_part_2.addObject(leaf_part_2)

App.ActiveDocument.rootPart_2.Placement=App.Placement(App.Vector(0,0,3), App.Rotation(App.Vector(0,0,1),0), App.Vector(0,0,0))
 
Gui.SendMsgToActiveView("ViewFit")
Gui.activeDocument().activeView().viewAxonometric()
part-hierarchy_2.png
part-hierarchy_2.png (152.81 KiB) Viewed 2766 times
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: STEP file read might be crazy long ...

Post by ickby »

In debug mode I always get a crash here, too. Looking at the code it became clear very quickly:
it crashes at this line: https://github.com/FreeCAD/FreeCAD/comm ... 40e832R125

And the reason is that you cannot iterate over a vector and modify its size at the same time. As soon as the insert method enlarges the array all iterators become invalid and still using them leads to undefined behaviour. See also: http://www.cplusplus.com/reference/vect ... or/insert/
Yes noticed this too in my local branch, stupid mistake. Thnaks for fixing.
thx
ATM I can assembly root Parts and leafs with python and apply a placement to roots
EDIT
is it possible to create a simple copy of the all Part assembly? (also may be with a python macro?)
Please open a new topic for such discussions, this has nothing to do with this thread.
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: STEP file read might be crazy long ...

Post by easyw-fc »

ickby wrote: Please open a new topic for such discussions, this has nothing to do with this thread.
the Part structure I posted is exactly the structure that would be probably in the new @vejmarie STEP importer, so I was trying to preview the result before the code changing, testing some user case...
(i.e. compound allows to have a mux of the assembly, but I cannot find a way to have the same with App::Part)
anyway if you think this is out of topic, feel free to move it to the right category...
Maurice
Post Reply