Using add_line to automatically create a new face
-
Hi all,
first message here, nice to meet you all. I'm a newbie with sketchup but ok at programming.
Now my question is:let's say I have built a piece of geometry, which is beautiful,
From Sketchup UI:
Adding just 1 line (from point A to point B) skectchup auto-generates a new polygon.From Ruby script API:
Using the same points A,B and using entities.add_line ... or add_edges etc there is indeed a line appearing in the model but it doesn't auto-generate the polygon.How can I auto-generate a polygon from the same configuration in the Ruby API?
Cheers
-
entities.add_face(args)
Where 'args' is a variety of things - e.g. a list or an array of [ordered] vertices or points or edges...
You might get those from a polygon/circle or your own added edges: but with points the edges are generated by the passed array.
http://www.sketchup.com/intl/en/developer/docs/ourdoc/entities#add_face
To make all faces that an edge can support, try usingedge.find_faces
There are many ways to achieve what you want...
It depends where you start... -
Hi TIG,
I've tried entities.add_face(args), which is how I create geometry normally. But the problem I have is more subtle.
It's the different behaviour between adding a line in sketchup (UI from mouse) and adding the same line from API call.If I draw the same line with the same points in sketchup (UI from mouse) on that particular piece of geometry it adds automatically a face (polygon), which is the intended result and it's correct.
If I call entities.add_face(edge) from ruby API either I get an error (too few parameters, at least 3 edges) or if I use entities.add_line(pointA, pointB) or entities.add_edge(pointA, pointB) it draws a line/edge but fails to create the face (polygon), which is not the same behaviour that I have if I do it manually with the mouse.
So is there a soft of global function to set to automagically create faces in those circumstances form API?
-
Sorry it looks like it's all working fine now.
I'm not quite sure what triggered it work maybe quitting sketchup and reloading it after a long session fixed it. -
To repeat from my previous post...
To make all faces that an edge can support, try usingedge.find_faces
If that edge can form a face [or faces] then the face[s] get added to the same context... -
Thanks I've missed that edge.find_faces, it works great.
I think the naming put me off as I wasn't expecting that it will also add faces, I just thought it was going to find potential faces, I think it should may be renamed: find_and_add_faces just for clarity.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register LoginAdvertisement