<div dir="ltr">No problem Todor, although it may be worth bearing in mind that these sorts of usability questions are typically better suited to the QGIS User mailing list and may get a better response from there.<div><br></div><div>In terms of your query, I would say it is certainly possible to achieve in QGIS, but there are a few limits to what is possible and what is practical.</div><div><br></div><div></div><div>Like I mentioned before, I believe what you are after is better served using raster files displaying your CAD information, so converting your DWGs to a raster format beforehand would be beneficial.</div><div><br></div><div><div>Previewing the DWG file itself in QGIS probably isn't easily feasible, the easiest approach likely being some sort of HTML viewer integration. You can also convert the DWG to GPKG using QGIS tools to make it easier to work with, but again I feel this is not what you seem to need for your use case.</div><div></div></div><div><br></div><div>I would expect some data from a DWG to be unsupported by QGIS when converting it, as well as having data which is outside of the drawing paperspace not be included in the preview image (amongst other issues depending on the structure/ design of the DWGs). Jorge outlined the code needed to load the DWG with an external program using an action as well, but that would specifically require loading an instance of a third party program. My suggestion would be to build the map project as outlined in the presentation with raster images, and attach an action to open the complete drawing for further introspection.</div><div><br></div><div>I have created a small demo project which demonstrates how to achieve the outcomes I described. It includes various actions for launching file previews and contains a number of different layer styles and approaches for rendering the data in various manners as you would like. You can also configure the feature identification tool to automatically load the feature form and use the QGIS drag and Drop form designer to configure an image preview. The project also demonstrates using the QGIS atlas feature with print layouts to achieve the specific outcome highlighted in the presentation document.</div><div><br></div><div><img src="cid:ii_krff44z90" alt="output_3.png" width="561" height="396"><br></div><div><br></div><div>You can download the files and project, DWG_integration_example.zip, from the following temporary file share:</div><div><br></div><div><a href="https://filebin.net/qxrw2xc94syeioo4" target="_blank">https://filebin.net/qxrw2xc94syeioo4</a><br></div><div><br></div><div>(The Chrome browser security may complain it is unsafe, but you should be able to download it with firefox or edge etc)</div><div><br></div><div>SHA256: 7E9E5A398BFAE4115EEE6D5C1B2073ED7314C6B7186AB61818D613B389991FD7<br></div><div></div><div><br></div><div>I used some sample DWGs from the internet and bulk exported them to PDF using TrueView before converting to PNG, so this is definitely something you can make at least semi-automatic. If you have access to autocad, I imagine there are a number of options available for bulk exporting/ plotting/ publishing, if not from within the software itself, certainly using AutoLisp.</div><div><br></div><div>You could of course try to build similar DWG viewing functionality and leverage it in QGIS similar to what I have demonstrated with raster data, but I doubt it would be practical.</div><div><br></div><div>I hope that this solves your issues and provides you with a strong starting point for configuring your project.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 22 Jul 2021 at 09:34, todor lambev <<a href="mailto:totolamb@abv.bg" target="_blank">totolamb@abv.bg</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>
Dear Charles, <div><br></div><div>Thank you very much for your reply. In fact this is my first time that I use QGIS-developer forum and I am pleasantly surprised that someone replied to my questions.</div><div><br></div><div>No on the topic. In the attached presentation you can find an explanation what I would like to receive as a final "product. Do you think that it is possible or at least someting similar? The idea of the hole excersice is to be able to make a quick visual check of all the profiles which I have in separate DWGs. </div><div><br></div><div><br>Best regards<br><pre><font face="Calibri, sans-serif"><span style="line-height:17.12px">Todor Lambev, PhD Student
</span></font><span style="line-height:17.12px;font-family:Calibri,sans-serif">- - - - -
</span><span style="line-height:17.12px;font-family:Calibri,sans-serif"><b>Institute of Oceanology
</b><i>Department of coastal zones dynamics
mob: +359 886 75 72 85;
Varna, Bulgaria
URL: <a href="http://www.io-bas.bg" target="_blank">http://www.io-bas.bg</a></i></span></pre><br><br><br><br>
>-------- Оригинално писмо --------
<br> >От: Charles Dixon-Paver <a href="mailto:charles@kartoza.com" target="_blank">charles@kartoza.com</a>
<br> >Относно: Re: [QGIS-Developer] DWG files preview in QGIS
<br> >До: todor lambev <<a href="mailto:totolamb@abv.bg" target="_blank">totolamb@abv.bg</a>>
<br> >Изпратено на: 20.07.2021 18:38
<br><br>
<div>
It's not totally clear to me what the objective is for your DWGs.
<div>
<br>
</div>
<div>
By "preview", do you mean wish to just view an overview image of the DWG contents? If that is the case, I would recommend using a separate command line/ batch process to produce raster format previews as DWGs. You can then create a new field for the accompanying raster file using the field calculator and QGIS expressions.
</div>
<div>
<div>
<br>
</div>
<div>
With the rasters you can use the preview option in the feature form, or even use a "Raster Image Marker" based symbol at certain scales to represent the DXF previews.
</div>
<div>
<br>
</div>
<div>
Another option for previews is to use the "Show map tips" option from the QGIS toolbars. In the "Display" section of the layer properties you will find that tooltips can use HTML code which will render a "web preview" of the feature when you hover the cursor on it. for example, the following should allow image previews:
</div>
<div>
<br>
</div>
<div>
<span style="font-family:monospace"><img src='file:///[% @project_folder || '/' || "image" %]' height=400 width=400 /></span>
<br>
</div>
<div>
<br>
</div>
<div>
In theory, you could likely combine this with a DWG rendering library such as
<a href="https://sharecad.org/it/DWGOnlinePlugin" target="_blank">https://sharecad.org/it/DWGOnlinePlugin</a> but I expect it will be difficult to use and not very efficient, hence why I would suggest converting the data to raster beforehand. One other thing you could do as well is to use the "web view" of the QGIS form to render an html template with an integrated viewer, but again, this is likely difficult and not necessary.
</div>
<div>
<br>
</div>
<div>
I am not aware of any "preview" plugin for rendering DWG data within QGIS.
</div>
<div></div>
<div>
<br>
</div>
<div>
If your aim is to "load" the DWG into your project from a command available within the point feature attributes, this is supported by using GitHub actions and some custom code, although the process may be quite cumbersome. Actions functionality was covered on the last QGIS Open Day[1] and I recommend watching the demonstration if that is your use case. Alternatively, there is also some written material on this topic [2] f you would prefer to start there
</div>
<div>
<br>
</div>
<div>
[1]
<a href="https://github.com/qgis/QGIS/wiki/QOD-June-2021#qgis-actions-deep-dive" target="_blank">https://github.com/qgis/QGIS/wiki/QOD-June-2021#qgis-actions-deep-dive</a>
<br>
</div>
<div>
[2]
<a href="https://courses.spatialthoughts.com/pyqgis-in-a-day.html#creating-custom-python-actions" target="_blank">https://courses.spatialthoughts.com/pyqgis-in-a-day.html#creating-custom-python-actions</a>
</div>
<div>
<br>
</div>
</div>
</div>
<br>
<div>
<div>
On Tue, 20 Jul 2021 at 16:40, todor lambev <
<a>totolamb@abv.bg</a>> wrote:
<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div>
Dear QGIS developers,
</div>
<div>
<br>
</div>
<div>
I have a strange need. Could you help me?
</div>
<div>
I have 30 000 DWG files that are not georeferenced, each file has unique and a specific name. I have a point shapefile which in its attribute table contains a column with the names of the *dwg files.
</div>
<div>
<br>
</div>
<div>
My question is: How I can load to preview the DWG files in QGIS next to the points or to preview the DWG by clicking on the point (similar to the photo preview widget)?
</div>
<div>
<br>
</div>
<div>
I hope that you won't skip my question and will help me to find a solution basically because otherwise, I have to do it manually...
</div>
<div>
</div>
<div>
Best regards
<br>
<pre><font face="Calibri, sans-serif"><span style="line-height:17.12px">Todor Lambev, PhD Student
</span></font><span style="line-height:17.12px;font-family:Calibri,sans-serif">- - - - -
</span><span style="line-height:17.12px;font-family:Calibri,sans-serif"><b>Institute of Oceanology
</b><i>Department of coastal zones dynamics
mob: +359 886 75 72 85;
Varna, Bulgaria
URL: <a href="http://www.io-bas.bg" target="_blank">http://www.io-bas.bg</a></i></span></pre>
</div>
</div> _______________________________________________
<br> QGIS-Developer mailing list
<br>
<a>QGIS-Developer@lists.osgeo.org</a>
<br> List info:
<a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
<br> Unsubscribe:
<a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
<br>
</blockquote>
</div>
</div></div>
</blockquote></div>