[QGIS-Developer] DWG files preview in QGIS

Charles Dixon-Paver charles at kartoza.com
Sun Aug 1 02:53:07 PDT 2021


Hi there.

I am unable to read your previous message as the supplied image seems to
have been converted to plain text. I would recommend sending a link via an
internet image service like https://imgur.com/

If you were unable to access or review the link to the demo project I
provided previously, I have added to my gdrive temporarily so that you may
download it.

https://drive.google.com/file/d/1PZLy5_M4n6se0D74AWplrmqwIXh5-ZCX/view?usp=sharing

In terms of the visualisation aspect, I think that has already been
addressed. Within the example project is a points layer which contains the
attributes linking to relevant files and many different layer styles for
you to review depending on how you want to visualise your data. Just right
click the layer and navigate to the styles section of the context menu.
These styles were available:

   - atlas - highlighting the currently active atlas feature as used in the
   layout
   - call_out - an example of using label callouts to identify relevant
   drawings for each feature based on offset attributes
   - default - simple points
   - offset_from_point - positioning the drawing adjacent to point using
   map scale and scale dependant rendering and a custom styled feature form
   for displaying the drawing for a feature from the identify tool
   - raster - replacing the point symbol with a picture of the drawing
   - raster_and_point - simple multilayered symbol example
   - raster_map_units - raster symbol set to use map units for size/ scale
   and daraw effects to help it stand out from background map
   - raster_scaled - A simple example of using a raster symbol with
   effective scale dependant rendering

I would be surprised if one of these styles (or indeed the available
actions and example layout) would not suit your needs with a bit of
additional configuration.

Regards


On Sun, 1 Aug 2021 at 10:56, todor lambev <totolamb at abv.bg> wrote:

> Thank you very much, Charles.
> It was a long week on the field / I had to do a significant bathymetric
> survey in the Black see / and I did not have the chance to work on this but
> I think that I will manage.
> I bought a DWG->PDF/PNG converter because I think that would be more
> reliable if you have to convert many files at once. With a few clicks, it
> converts all DWG files (almost 15 000) to PNG files. Than using the example
> sent by you I loaded all profiles in QGIS and now the only tricky part is
> the visualization... At the moment it looks like this:
>
> When I zoom in, I can see in more details but the zoom is limited... But I
> think that I could work with it.
>
> Thank you once again for your help and all the best.
>
> Todor Lambev, PhD Student- - - - -*Institute of Oceanology
> **Department of coastal zones dynamics
> mob: +359 886 75 72 85;
> Varna, Bulgaria
> URL: http://www.io-bas.bg <http://www.io-bas.bg>*
>
>
>
>
>
> >-------- Оригинално писмо --------
> >От: Charles Dixon-Paver charles at kartoza.com
> >Относно: Re: [QGIS-Developer] DWG files preview in QGIS
> >До: todor lambev <totolamb at abv.bg>
> >Изпратено на: 26.07.2021 10:28
>
> There should be no need to buy additional software to bulk convert DWG
> files to PNG format. If you have access to autocad you should be able to
> bulk export your layouts. I could likely share an auto lisp routine but
> without an autocad license and sample data I wouldn't be able to test it.
>
> As I said, I personally used the Autodesk True View application (which is
> free) to bulk export to pdf. You can also use a program like imagemajick to
> bulk convert PDF to PNG, so although it's a more complex workflow than
> exporting directly to PNG it is certainly possible without purchasing
> separate software.
>
> If you struggle with automating these steps let me know. I expect it to be
> quite a common procedure for users who work with CAD data and it may be
> worth a quick YouTube tutorial or similar. Even if it does take some extra
> time to develop, if you pay an open source consultant to develop a solution
> rather than paying for conversion software, everyone can benefit.
>
> On Mon, 26 Jul 2021, 01:31 todor lambev, < totolamb at abv.bg> wrote:
>
> Dear Charles,
>
> Thank you very much for your reply. I learned something new and usefull.
> I have to buy a DWG -> PNG convertor now but I think that will be fair if
> I need to preview all the files.
>
>
> Best regards
>
> Todor Lambev, PhD Student- - - - -*Institute of Oceanology
> **Department of coastal zones dynamics
> mob: +359 886 75 72 85;
> Varna, Bulgaria
> URL: http://www.io-bas.bg <http://www.io-bas.bg>*
>
>
>
>
>
> >-------- Оригинално писмо --------
> >От: Charles Dixon-Paver charles at kartoza.com
> >Относно: Re: [QGIS-Developer] DWG files preview in QGIS
> >До: todor lambev < totolamb at abv.bg>
> >Изпратено на: 23.07.2021 00:20
>
> 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.
>
> 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.
>
> 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.
>
> 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.
>
> 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.
>
> 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.
>
> [image: output_3.png]
>
> You can download the files and project, DWG_integration_example.zip, from
> the following temporary file share:
>
> https://filebin.net/qxrw2xc94syeioo4
>
> (The Chrome browser security may complain it is unsafe, but you should be
> able to download it with firefox or edge etc)
>
> SHA256: 7E9E5A398BFAE4115EEE6D5C1B2073ED7314C6B7186AB61818D613B389991FD7
>
> 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.
>
> 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.
>
> I hope that this solves your issues and provides you with a strong
> starting point for configuring your project.
>
> On Thu, 22 Jul 2021 at 09:34, todor lambev < totolamb at abv.bg> wrote:
>
> Dear Charles,
>
> 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.
>
> 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.
>
>
> Best regards
>
> Todor Lambev, PhD Student- - - - -*Institute of Oceanology
> **Department of coastal zones dynamics
> mob: +359 886 75 72 85;
> Varna, Bulgaria
> URL: http://www.io-bas.bg <http://www.io-bas.bg>*
>
>
>
>
>
> >-------- Оригинално писмо --------
> >От: Charles Dixon-Paver charles at kartoza.com
> >Относно: Re: [QGIS-Developer] DWG files preview in QGIS
> >До: todor lambev < totolamb at abv.bg>
> >Изпратено на: 20.07.2021 18:38
>
> It's not totally clear to me what the objective is for your DWGs.
>
> 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.
>
> 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.
>
> 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:
>
> <img src='file:///[%  @project_folder || '/' || "image" %]' height=400
> width=400 />
>
> In theory, you could likely combine this with a DWG rendering library such
> as https://sharecad.org/it/DWGOnlinePlugin 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.
>
> I am not aware of any "preview" plugin for rendering DWG data within QGIS.
>
> 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
>
> [1] https://github.com/qgis/QGIS/wiki/QOD-June-2021#qgis-actions-deep-dive
> [2]
> https://courses.spatialthoughts.com/pyqgis-in-a-day.html#creating-custom-python-actions
>
>
> On Tue, 20 Jul 2021 at 16:40, todor lambev < totolamb at abv.bg> wrote:
>
> Dear QGIS developers,
>
> I have a strange need. Could you help me?
> 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.
>
> 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)?
>
> 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...
>
> Best regards
>
> Todor Lambev, PhD Student- - - - -*Institute of Oceanology
> **Department of coastal zones dynamics
> mob: +359 886 75 72 85;
> Varna, Bulgaria
> URL: http://www.io-bas.bg <http://www.io-bas.bg>*
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210801/040ed202/attachment-0001.html>


More information about the QGIS-Developer mailing list