Page 1 of 1

how to delete all types outside a certain shape

Posted: Thu Aug 09, 2018 1:50 pm
by jurepriimek
Hello,

I am drawing a Voronoi grid and I would like to confine it with a square of certain dimensions that I can set. What I want to achieve (before and after) is seen in pictures 1 and 2.
Is there any way that this could be done automatically through a batch file rather doing it manually?

Thank you very much!

Re: how to delete all types outside a certain shape

Posted: Thu Aug 09, 2018 7:35 pm
by escolano
Maybe you are interested in directly using our plugin-tool: Geometry->Create->Voronoi...
It creates 2D or 3D voronoy geometries, with several options (number of random centers, or user defined, force periodic boundaries, ...)
this is a 2D example of the surfaces obtained with 15 random centers.
2D_voronoi_polygon_with_15_random_centers.png
2D_voronoi_polygon_with_15_random_centers.png (10.74 KiB) Viewed 6382 times

Re: how to delete all types outside a certain shape

Posted: Thu Aug 09, 2018 8:09 pm
by escolano
On the other hand, about your question,
to automatize your operation probably a batch is not enough, because you don't know a priori the entities to be selected, etc.
You must do it with a Tcl procedure, with full scripting control.
In Tcl you could use GiD_Process to send GiD keywords (like the batch)
or better, instead GiD_Process using some GiD-Tcl direct commands when possible, like GiD_Geometry.

You should do the steps that you are doing manually
-create your four 'trimming lines'
-intersect lines (try selecting all against all)
-delete the unwanted lines (and dependent points), selecting the ones to be removed with some geometrical criteria (e.g. with its center outside your trimming rectangle)

You can filter the lines you want for example with a Tcl procedure like this

Code: Select all

proc MyListLinesInrectangle { x_min x_max  y_min y_max } {
  set lines [list]
  foreach line_id [GiD_Geometry list line] {
     lassign [GidUtils::GetEntityCenter line $line_id] x y z
     if { $x >= $x_min &&  $x <= $x_max && $y >= $y_min &&  $y <= $y_max } {
       lappend lines $line_id
     }
  }
  return $lines
}

Re: how to delete all types outside a certain shape

Posted: Fri Aug 10, 2018 3:50 pm
by jurepriimek
Thank you very much for your reply!
For some reason it did not occur to me that there might a a plug-in that does something similar or even the same thing! Been working on this for a good while and havent made much progress - its all so pointless now. It solves all my problems.
Anyway, thank you for replying and offering the perfect solution.
Best Wishes