How to add vertex to a Surface from macro

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
l3VGV
Posts: 47
Joined: Sat Oct 12, 2019 11:04 am

How to add vertex to a Surface from macro

Post by l3VGV »

Im trying to manipulate Surface object from SurfaceWB, i want to add and remove vertexes from my script.

I found FreeCAD.ActiveDocument.Surface002.Points list, but ther is no reaction to clear() or

Code: Select all

for p in FreeCAD.ActiveDocument.Surface002.Points:
	FreeCAD.ActiveDocument.Surface002.Points.remove(p)

Is it possible at all to manipulate vertexes from python?
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: How to add vertex to a Surface from macro

Post by Chris_G »

The Points property is of type PropertyLinkSubList :

Code: Select all

>>> surface.getTypeIdOfProperty("Points")
'App::PropertyLinkSubList'
It is not possible to manipulate this list directly.
You must copy it to a temp list, do your stuff, and reassign the list as a whole :

Code: Select all

temp = surface.Points
temp.pop(1)
surface.Points = temp
l3VGV
Posts: 47
Joined: Sat Oct 12, 2019 11:04 am

Re: How to add vertex to a Surface from macro

Post by l3VGV »

Chris_G wrote: Sun Feb 02, 2020 9:08 am You must copy it to a temp list, do your stuff, and reassign the list as a whole
Thank you, that worked.

But, putting 4k+ points into a Surface was a bit too much.
Post Reply