Feature Request/Enhacement for Draft PathArray
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 225
- Joined: Fri Apr 26, 2019 3:14 pm
Feature Request/Enhacement for Draft PathArray
Hi all,
I hat a lot of trouble to align railway sleepers along a custom path while trying to use the draft PathArray function for positioning.
(I read trough DeepSoic's explanation for Draft-Patharray.)
I'd like to suggest to change the "align" option in that way that one could choose a certain (axle)Vector of the "replicated" object to follow the Frenet-Vector of the given path - while the others axles of the object staying unmodifed.
E.g. If you choose align "X" ... the Object in question will turn around the Z axle while following the path.
Kind regards, Stefan
I hat a lot of trouble to align railway sleepers along a custom path while trying to use the draft PathArray function for positioning.
(I read trough DeepSoic's explanation for Draft-Patharray.)
I'd like to suggest to change the "align" option in that way that one could choose a certain (axle)Vector of the "replicated" object to follow the Frenet-Vector of the given path - while the others axles of the object staying unmodifed.
E.g. If you choose align "X" ... the Object in question will turn around the Z axle while following the path.
Kind regards, Stefan
- wandererfan
- Veteran
- Posts: 6315
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: Feature Request/Enhacement for Draft PathArray
Without comment on the merits of the feature request ...C_h_o_p_i_n wrote: ↑Sun Apr 19, 2020 8:09 am I hat a lot of trouble to align railway sleepers along a custom path while trying to use the draft PathArray function for positioning.
(I read trough DeepSoic's explanation for Draft-Patharray.)
The relative scales of the ties (sleepers) vs the rail curvature may be throwing me off, but the ties should be aligned on the red lines, and not as shown.
As drawn, the base of the rail will not fit correctly into the groove on the tie plate and the spike holes will be obstructed.
My track side experience was quite some time ago (no, not in the steam era), so I may be out of date in these days of concrete ties and pandrol clips.
@Joel_graff may know more.
Joel_graff wrote: ping
Re: Feature Request/Enhacement for Draft PathArray
Indeed, there is something faulty.
The orientation AND the positioning are incorrect when align==true. Looks like a mixture of boundingbox positioning and random orientation. I am not a prgrammer and specially Python is for me pretty hard. In DraftTools.py
and in Draft.py
i do not get where the orientation is performed (defxlate, xlate?)
Greetings
The orientation AND the positioning are incorrect when align==true. Looks like a mixture of boundingbox positioning and random orientation. I am not a prgrammer and specially Python is for me pretty hard. In DraftTools.py
Code: Select all
class PathArray(Modifier):
"""The PathArray FreeCAD command definition"""
def __init__(self,use_link=False):
Modifier.__init__(self)
self.use_link = use_link
def GetResources(self):
return {'Pixmap' : 'Draft_PathArray',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_PathArray", "PathArray"),
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Draft_PathArray", "Creates copies of a selected object along a selected path.")}
def Activated(self):
Modifier.Activated(self)
if not FreeCADGui.Selection.getSelectionEx():
if self.ui:
self.ui.selectUi()
FreeCAD.Console.PrintMessage(translate("draft", "Please select base and path objects")+"\n")
# print("Please select base and path objects")
self.call = self.view.addEventCallback("SoEvent",selectObject)
else:
self.proceed()
def proceed(self):
if self.call:
self.view.removeEventCallback("SoEvent",self.call)
sel = FreeCADGui.Selection.getSelectionEx()
if sel:
base = sel[0].Object
path = sel[1].Object
pathsubs = list(sel[1].SubElementNames)
defXlate = FreeCAD.Vector(0,0,0)
defCount = 4
defAlign = False
FreeCAD.ActiveDocument.openTransaction("PathArray")
Draft.makePathArray(base,path,defCount,defXlate,defAlign,pathsubs,use_link=self.use_link)
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute() # feature won't appear until recompute.
self.finish()
Code: Select all
def makePathArray(baseobject,pathobject,count,xlate=None,align=False,pathobjsubs=[],use_link=False):
"""makePathArray(docobj,path,count,xlate,align,pathobjsubs,use_link): distribute
count copies of a document baseobject along a pathobject or subobjects of a
pathobject. Optionally translates each copy by FreeCAD.Vector xlate direction
and distance to adjust for difference in shape centre vs shape reference point.
Optionally aligns baseobject to tangent/normal/binormal of path."""
if not FreeCAD.ActiveDocument:
FreeCAD.Console.PrintError("No active document. Aborting\n")
return
if use_link:
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","PathArray",_PathArray(None),None,True)
else:
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython","PathArray")
_PathArray(obj)
obj.Base = baseobject
obj.PathObj = pathobject
if pathobjsubs:
sl = []
for sub in pathobjsubs:
sl.append((obj.PathObj,sub))
obj.PathSubs = list(sl)
if count > 1:
obj.Count = count
if xlate:
obj.Xlate = xlate
obj.Align = align
if gui:
if use_link:
_ViewProviderDraftLink(obj.ViewObject)
else:
_ViewProviderDraftArray(obj.ViewObject)
formatObject(obj,obj.Base)
if len(obj.Base.ViewObject.DiffuseColor) > 1:
obj.ViewObject.Proxy.resetColors(obj.ViewObject)
baseobject.ViewObject.hide()
select(obj)
return obj
Greetings
Re: Feature Request/Enhacement for Draft PathArray
The DraftTools.PathArray class defines the behavior of the button that you click to create arrays. The Draft.makePathArray function creates the new scripted object corresponding to a Path Array.
But the code that really defines how the array works is the Draft._PathArray class. It seems the Draft.calculatePlacementsOnPath function is the one defining how things should be placed on the path.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
-
- Posts: 225
- Joined: Fri Apr 26, 2019 3:14 pm
Re: Feature Request/Enhacement for Draft PathArray
Hello all,
It looks to me that that the Function "calculatePlacement" is responsible - on how the placement is done ...
I'll try to hav a look on it ... but i'm open to suggestions.
Thanks @vocx for pointing into the right direction !
Kind regards, Stefan
It looks to me that that the Function "calculatePlacement" is responsible - on how the placement is done ...
I'll try to hav a look on it ... but i'm open to suggestions.
Thanks @vocx for pointing into the right direction !
Kind regards, Stefan
-
- Posts: 225
- Joined: Fri Apr 26, 2019 3:14 pm
Re: Feature Request/Enhacement for Draft PathArray
Hello all,
I took a look ... and I must admit that my 3d Vector/matrices knowledge seems to got lost during the last 35 years ...
I took a look ... and I must admit that my 3d Vector/matrices knowledge seems to got lost during the last 35 years ...
Re: Feature Request/Enhacement for Draft PathArray
Mod edit: moved to Draft subforum
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Re: Feature Request/Enhacement for Draft PathArray
Hello!
Greetings
Thanks for that hint!
I saw that too. My skills in programming is also very limited. But i will try that. But i do not promise anything.C_h_o_p_i_n wrote: ↑Tue Apr 21, 2020 7:30 am It looks to me that that the Function "calculatePlacement" is responsible - on how the placement is done ...
Greetings
-
- Posts: 225
- Joined: Fri Apr 26, 2019 3:14 pm
Re: Feature Request/Enhacement for Draft PathArray
Hi,
As more as I’m thinking about the enhancement the more I come to the conclusion that the most universal enhancement would be to offer the possibility to let the user choose which object axis maps to which frenet axis with an optional angular displacement for each axis.
Just as an idea on how the property dialog might look in that case:
Align X: [None, Object-x, Object-y, Object-z]
Align Y: [None, Object-x, Object-y, Object-z]
Align Z: [None, Object-x, Object-y, Object-z]
Align angular displacement [+-0..90, ... etc
Due to the fact, being for the first time in contact with modifying FreeCAD source, my mayor problems would be the adding new menu options to the property dialog and hand the choice made through to the function as parameters.
I also presume, that the current code does not take a 3dimensional path into account but I might be wrong.
@user1234 ... let me know if I can help...
Kind regards,
Stefan
As more as I’m thinking about the enhancement the more I come to the conclusion that the most universal enhancement would be to offer the possibility to let the user choose which object axis maps to which frenet axis with an optional angular displacement for each axis.
Just as an idea on how the property dialog might look in that case:
Align X: [None, Object-x, Object-y, Object-z]
Align Y: [None, Object-x, Object-y, Object-z]
Align Z: [None, Object-x, Object-y, Object-z]
Align angular displacement [+-0..90, ... etc
Due to the fact, being for the first time in contact with modifying FreeCAD source, my mayor problems would be the adding new menu options to the property dialog and hand the choice made through to the function as parameters.
I also presume, that the current code does not take a 3dimensional path into account but I might be wrong.
@user1234 ... let me know if I can help...
Kind regards,
Stefan
Re: Feature Request/Enhacement for Draft PathArray
Me too, except some small experiments.
But i whould not make a dialog. Other Draft commands do not have them either. Also there is a big Draft cleanup in form as a pull request on GitHub.
https://github.com/FreeCAD/FreeCAD/pull/3367
But for today my time is up .....
Greetings