[Solved] Modify Macro Cut Line

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

[Solved] Modify Macro Cut Line

Post by jfc4120 »

I am using the following addin macro often:

https://wiki.freecad.org/Macro_Cut_Line

It works good but begins at the object start end.

Can someone help tweak it so if I click near one end it will start at the nearest end selected.

Modifying it is still higher than my current python level.
Attachments
cutline.png
cutline.png (40.38 KiB) Viewed 259 times
Last edited by jfc4120 on Thu Mar 16, 2023 2:18 am, edited 1 time in total.
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

Re: Modify Macro Cut Line

Post by jfc4120 »

I resolved it, not the best way, but I modifed this section:

Code: Select all

                KOUNT = 0

                for p in points:
                    #####added
                    KOUNT = KOUNT + 1

                    #####added
                    if createPoint != 0:
                        #Draft.makePoint(p.x, p.y, p.z)
                        ###added
                        if KOUNT == 1:
                            multlist = [[p.x, p.y, p.z]]
                        if KOUNT > 1:
                            multlist.append([p.x, p.y, p.z])
                        ####added
                    FreeCAD.Console.PrintMessage(
                        str(compteur) + " X" + str(p.x) + " Y" + str(p.y) + " Z" + str(p.z) + "\n")
                    #                        print( compteur," X", p.x, " Y", p.y, " Z", p.z)
                    print('p', p)
                print('multilist', multlist)
                print('kount', KOUNT)
                K = KOUNT

                for i in range(0, KOUNT):
                    K = K - 1          ################ points in reverse
                    print('k', K)
                    Draft.makePoint(multlist[K][0], multlist[K][1], multlist[K][2])
                    print('ml5', multlist[K][0])


Attached is whole file, I am not certain about the modifications in the second section, but it works for my use case:

Please post here any fixes.
Attachments
cut_line_regular_backwards.py
(5.41 KiB) Downloaded 6 times
Post Reply