Support for assembly2 continuing

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Support for assembly2 continuing

Post by easyw-fc »

after this PR in FreeCAD 0.17
https://github.com/FreeCAD/FreeCAD/pull/359
Path: Changed Part.Line to Part.LineSegment #359
Assembly2 will not work for some constraints related to:
Curves, Lines, Edges
in FC 0.17 from release 9123

any help from FC gurus would be highly appreciate :)
thx
Maurice

PS assembly2 in FC 0.16 is still fine
User avatar
yorik
Founder
Posts: 13660
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Support for assembly2 continuing

Post by yorik »

Have a look at the discussion here: viewtopic.php?f=10&t=18767&p=147194#p147194
Bascially now Part.Line is infinite.

There might be changes needed in Assembly2, but we need to isolate exactly where the errors happen
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Support for assembly2 continuing

Post by easyw-fc »

yorik wrote:Have a look at the discussion here: viewtopic.php?f=10&t=18767&p=147194#p147194
Bascially now Part.Line is infinite.

There might be changes needed in Assembly2, but we need to isolate exactly where the errors happen
Hi @yorik
thx for your prompt reply :)
the issues are related to this file:
https://github.com/hamish2014/FreeCAD_a ... bly2lib.py
with the function
LinearEdgeSelected
CircularEdgeSelected
getSubElementPos

the errors come when applying an Axial constraint for edges (using previous release) or for edges and planes (using latest assembly2)
Just substituting

Code: Select all

Part.Line
to

Code: Select all

Part.LineSegment
will partially solve the issue, but then it will appear in FC 016 where Part.LineSegment is not suitable
Moreover there will be still warning messages in FC017 related to Curve

Code: Select all

DeprecationWarning: For future usage 'Curve' will return 'Line' which is infinite instead of the limited 'LineSegment'.
If you need a line segment then use this:
Part.LineSegment(edge.Curve,edge.FirstParameter,edge.LastParameter)To suppress the warning set BaseApp/Preferences/Mod/Part/General/LineOld to false
thx for suggestions :)
Maurice
User avatar
yorik
Founder
Posts: 13660
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Support for assembly2 continuing

Post by yorik »

the solution we're now applying everywhere is to replace all

Code: Select all

isinstance(something,Part.Line)
with

Code: Select all

isinstance(something,(Part.Line,Part.LineSegment))
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Support for assembly2 continuing

Post by easyw-fc »

yorik wrote:the solution we're now applying everywhere is to replace all

Code: Select all

isinstance(something,Part.Line)
with

Code: Select all

isinstance(something,(Part.Line,Part.LineSegment))
very elegant solution! :ugeek:
I'm going to make a PR asap :D
thx a lot for this great software!

Maurice
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Support for assembly2 continuing

Post by easyw-fc »

Hi @yorik
oops ... it seems I tested too fast/roughly ...
changing the code to

Code: Select all

isinstance(something,(Part.Line,Part.LineSegment))
in FC 0.17 9123 the constraint work, but I still get this error/warning:

Code: Select all

DeprecationWarning: For future usage 'Curve' will return 'Line' which is infinite instead of the limited 'LineSegment'.
If you need a line segment then use this:
Part.LineSegment(edge.Curve,edge.FirstParameter,edge.LastParameter)To suppress the warning set BaseApp/Preferences/Mod/Part/General/LineOld to false
and in FC 0.16 6706 the constraint doesn't work and I get this error:

Code: Select all

addSelection: docName,obj.Label,sub = testPline2,cylinder_01,Face1
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 8, in allow
    return ValidSelection(SelectionExObject(doc, obj, sub))
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
addSelection: docName,obj.Label,sub = testPline2,cube_transparent_01,Edge6
Traceback (most recent call last):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 61, in addSelection
    self.parseSelectionFunction( self.selections)
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 20, in parseSelection
    if ValidSelection(s1) and ValidSelection(s2):
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\axialConstraint.py", line 12, in ValidSelection
    or LinearEdgeSelected(selectionExObj)\
  File "C:\Users\userM\AppData\Roaming\FreeCAD\Mod\FreeCAD_assembly2-PLinenew\assembly2lib.py", line 352, in LinearEdgeSelected
    if isinstance(edge.Curve, (Part.Line,Part.LineSegment)):
<type 'exceptions.AttributeError'>: 'module' object has no attribute 'LineSegment'
and here the updated repo:
https://github.com/easyw/FreeCAD_assembly2/tree/dev
testPline.FCStd
(3.98 KiB) Downloaded 76 times
thx again
Maurice
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: Support for assembly2 continuing

Post by ulrich1a »

easyw-fc wrote:and in FC 0.16 6706 the constraint doesn't work and I get this error:
The new code is not available in FreeCAD 0.16. So there is a problem for macro authors, having to support macros for FreeCAD 0.17 and FreeCAD 0.16. We now need two different versions of a macro or make a lot if-cases with different code for FreeCAD 0.17 and FreeCAD 0.16.
I do actually not remember, how to check the FreeCAD-Version but this needs then to be in a macro.

Ulrich
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: Support for assembly2 continuing

Post by easyw-fc »

ulrich1a wrote:
easyw-fc wrote:and in FC 0.16 6706 the constraint doesn't work and I get this error:
The new code is not available in FreeCAD 0.16. So there is a problem for macro authors, having to support macros for FreeCAD 0.17 and FreeCAD 0.16. We now need two different versions of a macro or make a lot if-cases with different code for FreeCAD 0.17 and FreeCAD 0.16.
I do actually not remember, how to check the FreeCAD-Version but this needs then to be in a macro.

Ulrich
please note that this option would require also a check on 0.17 release nbr, because FC 0.17 is not supporting the new code before release 9123...
an other option would be in something like

Code: Select all

try: 
except:
but only if there would not be a cleaner solution...
any suggestion would be greatly appreciate
Maurice
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: Support for assembly2 continuing

Post by ulrich1a »

easyw-fc wrote:please note that this option would require also a check on 0.17 release nbr, because FC 0.17 is not supporting the new code before release 9123...
You are right in this point. But as all users which work with a 0.17 release are using development releases, I would expect, that those can be asked to use a more actual one.

Ulrich
User avatar
yorik
Founder
Posts: 13660
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Support for assembly2 continuing

Post by yorik »

you could make a helper function like this, that should work for both 0.16 and 0.17:

Code: Select all

def isLine(something):
    if hasattr(Part,"LineSegment"):
        return isinstance(something,(Part.Line,Part.LineSegment))
    else:
        return isinstance(something,Part.Line)
Post Reply