[API] Edge.other_vertex unexpected return value
-
<span class="syntaxdefault"><br />edge1</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">vertices<br /></span><span class="syntaxcomment">#=> [#<Sketchup;;Vertex;0xef6b57c>, #<Sketchup;;Vertex;0xeef8ce8>]<br /><br /></span><span class="syntaxdefault">edge2</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">vertices<br /></span><span class="syntaxcomment">#=> [#<Sketchup;;Vertex;0xef3821c>, #<Sketchup;;Vertex;0xeea2eb0>]<br /><br /></span><span class="syntaxdefault">edge2</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">other_vertex</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> edge1</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start </span><span class="syntaxkeyword">)<br /></span><span class="syntaxcomment">#<Sketchup;;Vertex;0xef3821c><br /></span><span class="syntaxdefault"></span>
No errors raised. Not even
Nilreturned.Beware!
-
Wait, what? I tihnk I'm mis-reading what you've written. It looks like the 3rd line of code
edge2.other_vertex( edge1.start )returned a vertex object#<Sketchup::Vertex:0xef3821c>, which is the expected behavior.
-
Ahh, I see it now. you passed edge2 one of edge1's vertices, so it should not have found the partner to that vertex on edge2. Yikes! Good catch.
-
Aye!
If you are dealing with vertices, and you create a bug where you mix up your vertex references you might not notice it immediately as this method happily returns the first vertex in the edge which isn't the one pass in the argument. Garbage in - garbage out.
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