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!
how to delete all types outside a certain shape
Moderator: GiD Team
-
- Posts: 5
- Joined: Wed Aug 01, 2018 10:26 am
how to delete all types outside a certain shape
- Attachments
-
- picture1-before.png (162.21 KiB) Viewed 6384 times
-
- picture2-after.png (161.05 KiB) Viewed 6384 times
Re: how to delete all types outside a certain shape
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.
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.
Re: how to delete all types outside a certain shape
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
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
}
-
- Posts: 5
- Joined: Wed Aug 01, 2018 10:26 am
Re: how to delete all types outside a certain shape
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
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