As requested per PM:
<span class="syntaxdefault"><br /></span><span class="syntaxcomment"># Returns nil if the face is not a circle.<br /># Returns the radius on success.<br /></span><span class="syntaxdefault">def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_circle_radius</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">face</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">edges </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">outer_loop</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">edges<br /> edge </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">edges</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">]<br /> return </span><span class="syntaxdefault">nil unless edge</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">curve</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">is_a</span><span class="syntaxkeyword">?( </span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">ArcCurve </span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">edge</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">curve</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">radius<br />end<br /></span> <span class="syntaxdefault"><br /></span><span class="syntaxcomment"># Returns nil if the face is not a semi circle.<br /># (ArcCurve and one edge connecting each curve end)<br /># Returns the radius on success.<br /></span><span class="syntaxdefault">def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_semicircle_radius</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">face</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">edges </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">face</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">outer_loop</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">edges<br /> curve_edges </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">edges</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">select </span><span class="syntaxkeyword">{ |</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">| </span><span class="syntaxdefault">e</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">curve</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">is_a</span><span class="syntaxkeyword">?( </span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">ArcCurve </span><span class="syntaxkeyword">) }<br /> </span><span class="syntaxdefault">curve </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">curve_edges</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">first</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">curve<br /> </span><span class="syntaxkeyword">return </span><span class="syntaxdefault">nil unless curve_edges</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">all</span><span class="syntaxkeyword">? { |</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">| </span><span class="syntaxdefault">e</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">curve </span><span class="syntaxkeyword">== </span><span class="syntaxdefault">curve </span><span class="syntaxkeyword">}<br /> </span><span class="syntaxdefault">edge </span><span class="syntaxkeyword">= (</span><span class="syntaxdefault">edges </span><span class="syntaxkeyword">- </span><span class="syntaxdefault">curve_edges</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">first<br /> </span><span class="syntaxcomment"># At this point you have all the data;<br /> # curve refers to the ArcCurve of the semicircle<br /> # edge refers to the Edge connecting the ArcCurve's ends<br /></span><span class="syntaxdefault">end<br /></span>💡 LightUp 7.1 | SketchUp's only real-time renderer that uses object-based rendering
Download Trial
R