• Login
sketchucation logo sketchucation
  • Login
๐Ÿค‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

[Plugin] importDXFtext

Scheduled Pinned Locked Moved Plugins
165 Posts 18 Posters 84.8k Views 18 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    TIG Moderator
    last edited by 11 Nov 2015, 21:19

    I haven't tried it.
    Away from my PC now...
    BUT it should just find 'nil' text-entities to process...

    Since it's a flaky DXF I suggest you find how to make a 'good' one containing the 'text' ๐Ÿ˜•

    TIG

    1 Reply Last reply Reply Quote 0
    • T Offline
      TommyK
      last edited by 26 Nov 2015, 09:48

      Hi TIG.

      I tried to get this plugin working on SU 2016 and wasn't successful. I go the following error in the console...

      I was also importing DWG - is this an issue?

      Error: #<ArgumentError: invalid byte sequence in UTF-8> /Users/tk/Library/Application Support/SketchUp 2016/SketchUp/Plugins/importDXFtext.rb:123:instrip!'
      /Users/tk/Library/Application Support/SketchUp 2016/SketchUp/Plugins/importDXFtext.rb:123:in block in get_styles' /Users/tk/Library/Application Support/SketchUp 2016/SketchUp/Plugins/importDXFtext.rb:121:in upto'
      /Users/tk/Library/Application Support/SketchUp 2016/SketchUp/Plugins/importDXFtext.rb:121:in get_styles' /Users/tk/Library/Application Support/SketchUp 2016/SketchUp/Plugins/importDXFtext.rb:1721:in run_tool'
      /Users/tk/Library/Application Support/SketchUp 2016/SketchUp/Plugins/importDXFtext.rb:1729:in importDXFtext' /Users/tk/Library/Application Support/SketchUp 2016/SketchUp/Plugins/importDXFtext.rb:1737:in block in <top (required)>'
      SketchUp:1:in call'

      1 Reply Last reply Reply Quote 0
      • T Offline
        TIG Moderator
        last edited by 26 Nov 2015, 11:34

        A DWG [or a DWF] file is NOT a DXF !
        The former is in a proprietary 'binary' coding, the latter is in readable 'text'.
        This script reads the 'text' [DXF], finds various 'TEXT' entries etc, and uses that data to recreate the SKP's equivalent 'flat' 3d-TEXT objects.

        It will never work with another file type.
        So export your DWG as a DXF... and try again...
        ๐Ÿ˜’

        TIG

        1 Reply Last reply Reply Quote 0
        • T Offline
          TommyK
          last edited by 26 Nov 2015, 16:46

          Ah, understood. My apologies.

          1 Reply Last reply Reply Quote 0
          • D Offline
            daniele.capuccini
            last edited by 15 Jan 2016, 18:17

            Is it compatible with SketchUp 2016?
            Thanks

            1 Reply Last reply Reply Quote 0
            • T Offline
              TIG Moderator
              last edited by 17 Jan 2016, 12:43

              It should install and work in v2016 OK.
              Although it's RBZ is not yet signed for v2016, it should load OK in the default security mode - 'Unrestricted'...

              Please be aware of its usage / limitations - see its first post.

              nor non-ASCII DXF[x] files.

              If you want to import the DXF's Geometry, and then the overlaid Text from within it, then you should ensure that the DXF import options are the same both times, AND that the CAD origin is set to be preserved - this ensures that the geometry and text overlay properly - you can always select, then move the two imported components neared to the Model's origin afterwards, if needs be.
              Obviously the DXF must contain some Mtext, Dtext objects etc !

              TIG

              1 Reply Last reply Reply Quote 0
              • T Offline
                TommyK
                last edited by 4 Feb 2016, 13:47

                I've been getting an error that breaks your plugin for some files, TIG.
                gsub': invalid byte sequence in UTF-8 (ArgumentError)`

                It appears that my file had text that was not encoded in UTF-8. I added a line to your code to get it working.

                txt.strip! if txt txt.chomp! if txt txt = txt.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode('UTF-8') # added this line

                1 Reply Last reply Reply Quote 0
                • C Offline
                  cmeed
                  last edited by 19 Apr 2017, 10:37

                  HI Tig,
                  Thanks for creating this plugin.

                  I've followed, i hope, all the instructions on importing but most of the text is not showing up - the ruby console, in my humble knowledge (first time of using the console) shows some promising info that there is text information in the .dxf file - see attachment.
                  the regular import brought in all the relevant geometry, i also have a .pdf of the .dwg file (that this .dxf file was made from) which shows there is text information.
                  I do get a small amount of text that shows up.(see image)
                  I've imported in 'mm' which is correct - they've just emailed to confirm

                  I was wondering, as it looks like there's info coming in, that I've done something wrong -
                  I've unhidden everything
                  I've checked all layers are visible too ......mmmmm
                  is there anything else i need to try?

                  I've sent you the .dxf file - it will be PM'ed on finishing this.....

                  cheers
                  Chris


                  2017-04-19_11-15-04.jpg


                  2017-04-19_11-23-40.jpg


                  all imported text in blue

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    TIG Moderator
                    last edited by 19 Apr 2017, 12:11

                    You first import the DXF keeping the CAD origin in the import options.
                    This must be kept to maintain the correct location of the text in later steps.
                    Set the units to be whatever the DXF was saved in...
                    If you are not sure then mm is probably the safest ?

                    Now run the DXF-text importer, using the same units etc...

                    It can take a loooong time to import a lot of text from a DXF.

                    I tested your DXF and got an error after it processed the text, and then placed the first piece temporarily at the origin.
                    I suspect it's an issue with the way the newer Ruby methods in v2017 processes some objects.

                    This is an old clunky script, so I'll look at a fix asap...

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • C Offline
                      cmeed
                      last edited by 19 Apr 2017, 12:54

                      Thanks tig that's amazing.

                      Yes I followed your 1st post instructions. Origin etc all the same.

                      Thanks for looking into it!

                      1 Reply Last reply Reply Quote 0
                      • T Offline
                        TIG Moderator
                        last edited by 19 Apr 2017, 15:04

                        I have now updated it and will be adding it to the PluginStore shortly...
                        I fixed the glitch with the new Ruby methods and also updated it somewhat, so it now runs slightly differently and is much faster [although < 1 second per text element added can still seem a long time!], and it also now reports its progress better etc...
                        I'll post here when it's ready.

                        I could also PM you your updated SKP back - 28Mb ! ...
                        But it could be slimmed down considerably, so it'd process quicker and give cleaner results.
                        For example some of the blocks of disclaimer text are constrained in CAD by using a boundary rather than newline carriage-returns, so when they import they are one long string rather than say 6 lines of text.
                        Either edit this kind of Mtext in CAD before making the DXF, or delete it completely as I can't see what use it is in the SKP anyway.
                        So perhaps fix issues with the DXF's text first and then process it yourself once v2.0 is posted ?

                        PS: Trimble's signing portal is down at the moment so I can't complete the update...
                        Watch this space...

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • C Offline
                          cmeed
                          last edited by 19 Apr 2017, 15:38

                          Tig! your're amazing!

                          Thanks for the advise on the Autocad and how to slim it down. I didn't create the original - i don't own any autocad software, I think Draftsight wafted past my computer a few months ago, but i have no way of altering the initial file. It was given to me as a Favour from the Studios, I won't on this occasion ask to change it, as i know I'll only bug them. I'll see them face to face tomorrow so i will ask then. but what you've done far exceeds expectation!! Amazing job cheers
                          c

                          1 Reply Last reply Reply Quote 0
                          • T Offline
                            TIG Moderator
                            last edited by 19 Apr 2017, 16:50

                            Here's v2.0 http://sketchucation.com/pluginstore?pln=importDXFtext
                            It is now compatible with newer SketchUp's Ruby versions.
                            It is also now made as a signed extension.
                            Read the 'More Info...' link for all of the changes...

                            TIG

                            1 Reply Last reply Reply Quote 0
                            • C Offline
                              cmeed
                              last edited by 19 Apr 2017, 17:34

                              it worked! ..... but it did'nt line up with the geometry. there was a 3 at the origin.
                              i have now eyeballed it refering to my pdf's and its good enough for tomorrow. I will investigate further when i have more time tomorrow and get back to you with results. imported units were the same with text and geometry....

                              ps it might be worth highlighting you have to put in exactly - TIG::ImportDXFtext.new - to those unfamilar with the ways of the consol. A couple of trys and i was there but I'd not put a capital I for Import. ooh its so picky .....

                              Great work non-the-less!!!!
                              c

                              1 Reply Last reply Reply Quote 0
                              • T Offline
                                TIG Moderator
                                last edited by 19 Apr 2017, 17:42

                                I recommend you use the File menu option and keep the Console closed.
                                It will run faster...

                                TIG

                                1 Reply Last reply Reply Quote 0
                                • E Offline
                                  Einstein
                                  last edited by 17 Sept 2020, 12:01

                                  Should it work with SU 2020?
                                  Because it doesn't work for me. I saved from AutoCAD as old version of DXF as possible (2000/LT2000 DXF) and imported the file into SketchUp. All relevant layer were ON.
                                  SketchUp only imported an empty layer on which I had my dimensions but did not import a layer on which I had text. In statistics it shows no entities.
                                  CTRL+A results in empty selection. Also there is nothing to unhide.

                                  Could you please take a look at the DXF, maybe try to import it and help me track the issue?
                                  I have no other version of SketchUp to try.


                                  forum.dxf

                                  1 Reply Last reply Reply Quote 0
                                  • T Offline
                                    TIG Moderator
                                    last edited by 17 Sept 2020, 14:59

                                    There are 1683 text-entities in the DXF !
                                    Did you check that the geometry [and text import afterwards] of the DXF preserved the origin in the Import Options settings...
                                    Did you use the same units settings.
                                    Did you run it with the Ruby Console open ?

                                    I do get an error message - I'm checking it out - I suspect it's the way that newer SketchUp handles references to deleted [non-existent] objects !

                                    TIG

                                    1 Reply Last reply Reply Quote 0
                                    • E Offline
                                      Einstein
                                      last edited by 18 Sept 2020, 01:11

                                      I now removed most of the text before saving to DXF, to do a little, easy test-drive.
                                      Console closed.
                                      I used the same units - first saved DWG in AutoCAD in millimetres, then saved DXF, then imported to SketchUp as millimetres.
                                      Still no success.
                                      Where are the import options settings? Do you mean regular DXF import?

                                      1 Reply Last reply Reply Quote 0
                                      • T Offline
                                        TIG Moderator
                                        last edited by 18 Sept 2020, 14:46

                                        The reused Import Options for the DXF text must be the same as the main DXF's Import Options, and preserve the CAD-origin.
                                        Many of your text strings contain special Unicode encoding.
                                        Many are trapped already like ยฐ, but some are sneaking through.
                                        Unexpectedly trying to add those as 3Dtext into the model causes everything to fail very catastrophically!
                                        I'm looking at ways to trap for this... so far unsuccessfully...

                                        I'll be back...

                                        TIG

                                        1 Reply Last reply Reply Quote 0
                                        • E Offline
                                          Einstein
                                          last edited by 19 Sept 2020, 00:57

                                          Well, I didn't do any kind of sorcery over that text ๐Ÿ˜„ It is simply AutoCAD text and dimensions.
                                          I would be very thankful if you could resolve it but don't bother if you don't have time.

                                          If I only import text, without any other stuff, is it still relevant that DXF native and your import options must match?

                                          1 Reply Last reply Reply Quote 0
                                          • 1
                                          • 2
                                          • 3
                                          • 4
                                          • 5
                                          • 8
                                          • 9
                                          • 3 / 9
                                          • First post
                                            Last post
                                          Buy SketchPlus
                                          Buy SUbD
                                          Buy WrapR
                                          Buy eBook
                                          Buy Modelur
                                          Buy Vertex Tools
                                          Buy SketchCuisine
                                          Buy FormFonts

                                          Advertisement