Joining lines programmatically does not close join window

Moderator: GiD Team

Post Reply
awa5114
Posts: 43
Joined: Thu Jan 26, 2017 5:10 pm

Joining lines programmatically does not close join window

Post by awa5114 »

I am trying to execute a simple macro with the following code:

Code: Select all

GiD_Process Mescape Geometry Create Line 0,-10,0 0.5,-10,0 20,-10,0 20,0,0 20,1,0 0.5,1,0 0,1,0 0,0,0 0,-10,0 old Mescape
The idea is to join the last line to the first (already existing or old) point. THe shape is constructed correctly and I believe no new point is created which is good. However the "Create point Procedure dialog box" (see attachment) still appears. The command window shows:
Create a new point or Pick the existing one? /n Joining to existing point /n leaving line creation. 8 new lines /n leaving line creation. 0 new lines /n unknown command ->
old
Why does this happen? and how can I get rid of the dialog box once and for all for a clean macro?
Attachments
Dialog box.PNG
Dialog box.PNG (13.48 KiB) Viewed 5164 times
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: Joining lines programmatically does not close join window

Post by escolano »

You must not finish repeating the first coordinate (0,-10,0) and the word 'old'

GiD_Process Mescape Geometry Create Line 0,-10,0 0.5,-10,0 20,-10,0 20,0,0 20,1,0 0.5,1,0 0,1,0 0,0,0 0,-10,0 old Mescape

instead must use Join and then provide the integer id of the point to be joined, not a 3D coordinate
e.g. if your model was empty you know that the if of the first point is '1'
GiD_Process Mescape Geometry Create Line 0,-10,0 0.5,-10,0 20,-10,0 20,0,0 20,1,0 0.5,1,0 0,1,0 0,0,0 Join 1 escape
or more general
set point_id [expr [GiD_Info Geometry MaxNumPoints]+1]

Code: Select all

GiD_Process Mescape Geometry Create Line 0,-10,0 0.5,-10,0 20,-10,0 20,0,0 20,1,0 0.5,1,0 0,1,0 0,0,0 Join $point_id escape
when creating straight lines do you have also the word 'Close' to create a last line joining with the first point of the current collection of lines

Code: Select all

GiD_Process Mescape Geometry Create Line 0,-10,0 0.5,-10,0 20,-10,0 20,0,0 20,1,0 0.5,1,0 0,1,0 0,0,0 Close Escape
and a final observation of interest for customization (to avoid checks a the posibility of raise the 'old'/'new' point related window)
there is a global GiD variable that you can temporary set to say GiD that all your coordinates must be considered as 'new points', without take into account if there are other close points.

Code: Select all

set old_value [GiD_Set CreateAlwaysNewPoint]
GiD_Set CreateAlwaysNewPoint 1
... create all your points
GiD_Set CreateAlwaysNewPoint $old_value ;#to restore its value
awa5114
Posts: 43
Joined: Thu Jan 26, 2017 5:10 pm

Re: Joining lines programmatically does not close join window

Post by awa5114 »

Yes. This works thanks. But I ran into another related issue. What if the first point I am trying to add is an old/join point and the second point is a new/unjoined point. Starting from the same geometry above we have:

GiD_Process Mescape Geometry Create Line 0,-10,0 0.5,-10,0 20,-10,0 20,0,0 20,1,0 0.5,1,0 0,1,0 0,0,0 Join 1 escape ---> WORKS NO PROBLEM
GiD_Process Mescape Geometry Create Line Join 8 escape 0.5,0,0 ---> DOES NOT WORK

Meaning I would like to start from old point with ID 8 (located at x = 0,y = 0,z = 0) and add a new point (located at x = 0.5,y = 0,z = 0). How would I go about doing that? I tried the second GID_process line above but no success.
User avatar
escolano
Posts: 1918
Joined: Sun Sep 05, 1982 10:51 pm

Re: Joining lines programmatically does not close join window

Post by escolano »

You must swap between both modes old id/new coordinate with the keywords Join/NoJoin or better for a batch FJoin/FNoJoin
(note the 'F' that mean 'Force' to not complain if trying to set Join when we are already in Join mode)

e.g.
GiD_Process Mescape Geometry Create Line FJoin 8 FNoJoin 0.5,0,0 escape
Post Reply