[REQ] label points with same X,Y Coordinates -pointcloud aid
-
Using points_cloud_triangulation.rb
In some cases there are whole areas that aren't triangulated, or areas that the triangulation is overlapping. (see images)
following the error message in the console, I figured that the problem occurs when there are points that share a common X,Y coordinate (on a different Z).It is a tedious task to find these points throughout a large model. I was wondering if there might be a script to label points that share the same Z? something similar to labeling stray lines - in "stray lines.rb".
Or if anybody knows how to write a script that would do that!?
-
Try this
require 'sketchup.rb' def cpointseqxy() model=Sketchup.active_model ents=model.active_entities layers=model.layers tlayer=layers.add("cpointseqxy") sel=model.selection sela=sel.to_a sel.clear model.start_operation("cpointseqxy") cs=[] ca=[] sela.each{|e| cs<< e if e.class==Sketchup;;ConstructionPoint ca<< e if e.class==Sketchup;;ConstructionPoint } th=[] ch=[] lh=[] ca.each{|c| cx=[] cs.each{|e| next if c.to_s == e.to_s if c.position.x == e.position.x and c.position.y == e.position.y cx<< e ch<< e t=ents.add_text(" =XY",e.position) th<< t l=ents.add_cline(c.position,e.position) lh<< l end#if } cs=cs-cx } th.each{|t|t.layer=tlayer} lh.each{|l|l.layer=tlayer} sel.add(th+ch+lh) model.commit_operation end
Copy + Paste the code into a file in the Plugins folder called
cpointseqxy.rb
.
Restart SUp and select everything [only cpoints get processes anyway].
In the Ruby Console typecpointseqxy
and all cpoints with common X & Y values are highlighted and highlighted=XY
text is added next to each of them, also a highlighted vertical cline is added between them. Note that the text and clines are also put onto a layer called 'cpointseqxy' - so you can isolate them or delete them more easily [by deleting the layer and its contents]... -
Hi,
@unknownuser said:
the problem occurs when there are points that share a common X,Y coordinate (on a different Z)
Correct. Delauney algorithm is a 2D triangulation process, sort of. Having 2 points at the same location (plan view) breaks it.
Note: the "Points are not planar" error can also occur if 2 points are very very very close to each other. It is a Sketchup "add_face" method issue, IMHO.
-
Very nice TIG! You're the man!
It works wonderfully!Could you have the text that's added, with arrows just like in "straylines.rb". I think it would make it easier on the eyes to find the points. I've added one arrow to demonstrate the difference, see attached image.
Thanks! really great!!
-
@didier bur said:
Note: the "Points are not planar" error can also occur if 2 points are very very very close to each other. It is a Sketchup "add_face" method issue, IMHO.
There is a way to overcome the problem of very close points not closing faces. scale the the model x10. add the faces, and then rescale by .1. It usually works.
Thanks guys!
-
Try this
require 'sketchup.rb' def cpointseqxy() model=Sketchup.active_model ents=model.active_entities layers=model.layers tlayer=layers.add("cpointseqxy") sel=model.selection sela=sel.to_a sel.clear vec=[10,10,10] ### change these values for arrow length model.start_operation("cpointseqxy") cs=[] ca=[] sela.each{|e| cs<< e if e.class==Sketchup;;ConstructionPoint ca<< e if e.class==Sketchup;;ConstructionPoint } th=[] ch=[] lh=[] ca.each{|c| cx=[] cs.each{|e| next if c.to_s == e.to_s if c.position.x == e.position.x and c.position.y == e.position.y cx<< e ch<< e t=ents.add_text(" =XY",e.position,vec) th<< t l=ents.add_cline(c.position,e.position) lh<< l end#if } cs=cs-cx } th.each{|t|t.layer=tlayer} lh.each{|l|l.layer=tlayer} sel.add(th+ch+lh) model.commit_operation end
This has arrows for the text:
vec=[10,10,10]
sets the arrows 'vector', adjust the value of it to change the leader location, length etc...
Advertisement