Project

General

Profile

Automatic export from QGis to dxf » History » Version 2

Giulio Di Anastasio, 29/04/2021 16:58

1 1 Giulio Di Anastasio
h1. Automatic export from QGis to dxf
2 2 Giulio Di Anastasio
3 2 Giulio Di Anastasio
QGis Graphical Modeler:
4 2 Giulio Di Anastasio
An algorithm to automatically export data 
5 2 Giulio Di Anastasio
directly from Gisaf to .dxf format (CAD)
6 2 Giulio Di Anastasio
7 2 Giulio Di Anastasio
-	Login to PostGIS
8 2 Giulio Di Anastasio
-	Directly from the Gisaf server, load all the layers which need to be converted into .dxf format
9 2 Giulio Di Anastasio
-	Go to Processing Menu, click on “Graphical Modeler” (or Ctrl+Alt+G)
10 2 Giulio Di Anastasio
11 2 Giulio Di Anastasio
 
12 2 Giulio Di Anastasio
13 2 Giulio Di Anastasio
The “Model Designer” window will open:
14 2 Giulio Di Anastasio
 
15 2 Giulio Di Anastasio
The final model will look like this:
16 2 Giulio Di Anastasio
17 2 Giulio Di Anastasio
 
18 2 Giulio Di Anastasio
19 2 Giulio Di Anastasio
Below, the explanation on how the algorithm has been created.
20 2 Giulio Di Anastasio
-	An input to the algorithm is needed: go to “Inputs” tab and double click on “Vector Layer”.
21 2 Giulio Di Anastasio
 
22 2 Giulio Di Anastasio
23 2 Giulio Di Anastasio
The window “Input Vector layer Parameter Definition” will open:
24 2 Giulio Di Anastasio
-	in “Description”, enter “Input Vector layer”
25 2 Giulio Di Anastasio
-	in “Geometry type” select “Any Geometry Type”
26 2 Giulio Di Anastasio
-	Click “Ok”
27 2 Giulio Di Anastasio
 
28 2 Giulio Di Anastasio
29 2 Giulio Di Anastasio
Input is created as above.
30 2 Giulio Di Anastasio
As a second step, features need to be filtered, because some layers have different “Status” (E, D, F, etc. as defined in CSR Geomatics CAD Layer Naming Standards):
31 2 Giulio Di Anastasio
-	in the Algorithms panel, type “filter” in the Search Box: this way, all existing algorithms related to “filter” will be listed
32 2 Giulio Di Anastasio
-	double click on “Feature filter”
33 2 Giulio Di Anastasio
34 2 Giulio Di Anastasio
 
35 2 Giulio Di Anastasio
“Feature filter” window will open:
36 2 Giulio Di Anastasio
 
37 2 Giulio Di Anastasio
-	Click on ‘Add output filter’ icon,
38 2 Giulio Di Anastasio
 
39 2 Giulio Di Anastasio
-	Click on expression button  , to write an expression for the filter.
40 2 Giulio Di Anastasio
-	The Expression dialog will open, type the criteria for defining the filter, e.g. “STATUS”=’E’
41 2 Giulio Di Anastasio
42 2 Giulio Di Anastasio
 
43 2 Giulio Di Anastasio
-	Click “Ok”: the expression is added in the table of “Outputs and filters” as below.
44 2 Giulio Di Anastasio
-	In the field “Output Name”, type in the output as ‘E’.
45 2 Giulio Di Anastasio
46 2 Giulio Di Anastasio
 
47 2 Giulio Di Anastasio
-	Repeat the same steps for all other status (Like D,F,N,T,M and X)
48 2 Giulio Di Anastasio
-	Click on the “Input layer” button and select “Model Input” in the drop-down list, it will change to “Input Vector layer”. Click on “Ok”. 
49 2 Giulio Di Anastasio
 
50 2 Giulio Di Anastasio
51 2 Giulio Di Anastasio
 
52 2 Giulio Di Anastasio
53 2 Giulio Di Anastasio
The model will look like below:
54 2 Giulio Di Anastasio
 
55 2 Giulio Di Anastasio
56 2 Giulio Di Anastasio
As the input layers were taken directly from Gisaf server, where their CRS is WGS 84-EPSG:4326, all outputs need to be reprojected in TM AUSPOS CRS, because the CAD overall survey map is in TM AUSPOS:
57 2 Giulio Di Anastasio
-	Go to “Algorithms” panel and type “reproject” in the Search Box: this way, all existing algorithms related to “reproject” will be listed
58 2 Giulio Di Anastasio
-	Double click on “Reproject layer” under “Vector general”.
59 2 Giulio Di Anastasio
60 2 Giulio Di Anastasio
 
61 2 Giulio Di Anastasio
The “Reproject layer” dialog will open:
62 2 Giulio Di Anastasio
In the “Description” box type “Reproject layer ‘E’”: this will reproject only the features with status ‘E’.
63 2 Giulio Di Anastasio
 
64 2 Giulio Di Anastasio
-	In “Input layer” drop-down select “Algorithm Output”, click on the related box and a list of all available algorithm outputs will appear.
65 2 Giulio Di Anastasio
-	In “Using algorithm output” select ““E” from algorithm “Feature filter””
66 2 Giulio Di Anastasio
67 2 Giulio Di Anastasio
 
68 2 Giulio Di Anastasio
69 2 Giulio Di Anastasio
-	In “Target CRS” select “USER;100028-TM AUSPOS”
70 2 Giulio Di Anastasio
71 2 Giulio Di Anastasio
-	Click “Ok”. The model will look like below:
72 2 Giulio Di Anastasio
 
73 2 Giulio Di Anastasio
74 2 Giulio Di Anastasio
-	Follow the same steps for all the status (N, D, F, T, M, X), from “Reproject” onwards
75 2 Giulio Di Anastasio
Once finished, the model will look like this:
76 2 Giulio Di Anastasio
 
77 2 Giulio Di Anastasio
The final step of the algorithm is to convert the outputs to .dxf format:
78 2 Giulio Di Anastasio
-	Go to “Algorithms” panel, type “dxf” in the Search Box: this way, all existing algorithms related to “dxf” will be listed,
79 2 Giulio Di Anastasio
-	Double click on “v.out.dxf” from “GRASS”
80 2 Giulio Di Anastasio
81 2 Giulio Di Anastasio
-	The “v.out.dxf” window will open. In “Description” type “v.out.dxf ‘E’”
82 2 Giulio Di Anastasio
-	In “Name of input vector map”, click on the button and select “Algorithm output”
83 2 Giulio Di Anastasio
 
84 2 Giulio Di Anastasio
85 2 Giulio Di Anastasio
-	In the drop-down list, select ““Reprojected” from algorithm “Reproject layer “E””.
86 2 Giulio Di Anastasio
 
87 2 Giulio Di Anastasio
-	In “DXF vector” type “DXF ‘E’”. This means that the dxf is the final output of the algorithm.
88 2 Giulio Di Anastasio
89 2 Giulio Di Anastasio
 
90 2 Giulio Di Anastasio
91 2 Giulio Di Anastasio
-	Click “Ok”. Now the model will be as below:
92 2 Giulio Di Anastasio
 
93 2 Giulio Di Anastasio
-	Repeat the same steps for all other status.
94 2 Giulio Di Anastasio
95 2 Giulio Di Anastasio
96 2 Giulio Di Anastasio
 
97 2 Giulio Di Anastasio
The algorithm is now ready to convert QGis layers to .dxf format.
98 2 Giulio Di Anastasio
-	To save the model, click on   “Save”
99 2 Giulio Di Anastasio
-	“Save Model” window will open, give a name to the model (e.g. ‘Export SHP to DXF’) and save it.
100 2 Giulio Di Anastasio
101 2 Giulio Di Anastasio
 
102 2 Giulio Di Anastasio
103 2 Giulio Di Anastasio
Once saved in the QGis models folder, the model can be opened from the Graphical Modeler and used directly:
104 2 Giulio Di Anastasio
-	Click  on   “Run model” icon.
105 2 Giulio Di Anastasio
106 2 Giulio Di Anastasio
The “Model” Dialog box will open:
107 2 Giulio Di Anastasio
 
108 2 Giulio Di Anastasio
-	Click  on “Run as Batch Process”(bottom left corner),
109 2 Giulio Di Anastasio
-	Batch Processing window will open
110 2 Giulio Di Anastasio
-	Click on “Autofill” under ‘Input Vector layer’
111 2 Giulio Di Anastasio
-	In the drop-down window, click on “Select from Open Layers”,
112 2 Giulio Di Anastasio
113 2 Giulio Di Anastasio
-	The ‘Multiple selection’ box will open, click on “Select all”, then click on “Ok”.
114 2 Giulio Di Anastasio
 
115 2 Giulio Di Anastasio
116 2 Giulio Di Anastasio
Now all the layers are selected for the process.
117 2 Giulio Di Anastasio
 
118 2 Giulio Di Anastasio
-	Click on   on first layer, first status (e.g.: under “dxf ’E’”)
119 2 Giulio Di Anastasio
The “Save file” window will open
120 2 Giulio Di Anastasio
 
121 2 Giulio Di Anastasio
-	Select the folder where to save and type in the letter indicating the status followed by a hyphen (e.g. “E-“) and click on “Ok” 
122 2 Giulio Di Anastasio
-	The “Autofill settings” box will open:
123 2 Giulio Di Anastasio
-	In “Autofill mode”, select “Fill with parameter values”
124 2 Giulio Di Anastasio
-	In “Parameter to use”, select “Input Vector layer”
125 2 Giulio Di Anastasio
-	Click on “Ok”: it will automatically fill for other layers also.
126 2 Giulio Di Anastasio
127 2 Giulio Di Anastasio
 
128 2 Giulio Di Anastasio
129 2 Giulio Di Anastasio
-	Follow the same steps for all other status outputs.
130 2 Giulio Di Anastasio
-	Once details for all the status are entered, click on “Run” for the process to execute.
131 2 Giulio Di Anastasio
 
132 2 Giulio Di Anastasio
-	Once done, click on “Close”. 
133 2 Giulio Di Anastasio
-	All dxf files are exported into the selected folder, with the status followed by the name of the layers.
134 2 Giulio Di Anastasio
135 2 Giulio Di Anastasio