sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    [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.
    • A Offline
      alexdobras
      last edited by

      @tig said:

      BUT you tried to import it in 'mm'... I did it in 'm' - as I explained before.......
      I worked fine for me...
      WHAT are the units you are working in ... 😲

      sorry TIG, i knew i forgot to change something.
      when putting to m , it works,
      but i don't understand why is crashing at mm, though.
      and a second one, why the file needs to be saved as 2004 ascii dxf, could;nt you make it up-to-date to ascii 2010 drawing?

      thanks anyways for this wonderful plugin!

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        @alexdobras said:

        @tig said:

        BUT you tried to import it in 'mm'... I did it in 'm' - as I explained before.......
        I worked fine for me...
        WHAT are the units you are working in ... 😲

        sorry TIG, i knew i forgot to change something.
        when putting to m , it works,
        but i don't understand why is crashing at mm, though.
        and a second one, why the file needs to be saved as 2004 ascii dxf, could;nt you make it up-to-date to ascii 2010 drawing?
        Thanks anyways for this wonderful plugin!

        Presumably at 'mm' the size of some objects is just too small of Sketchup/OpenGL <~0.5mm - You OUGHT to import all of your DXFs etc in at their correct unit settings - I assumed 'm' as it simply 'worked' and you [still] gave me no clue - CAD files have no real UNITS - the recipient must be told that vital info so the units can be 'set' on import !??
        Please remember that this is a ***ing 'free tool' πŸ˜’ I wrote it to read DXF format files as they were made at that time - so your saving it in a more recent DXF format gives YOU absolutely NO benefits and me only a headache...
        Reading the code in a DXF file is complex enough to 'parse' - even in its 'text' format - I suggest you open a DXF file in Notepad to see what I mean... A binary format like DWG is a zillion times more involved [open one in Notepad to see the gobbledygook]... So... IF YOU want to write your own DXF importer and share it freely with the rest of us, then please feel free 😒
        Gift horse...mouth... etc 😠

        TIG

        1 Reply Last reply Reply Quote 0
        • A Offline
          alexdobras
          last edited by

          "you [still] gave me no clue" - i don't exactly understand what are you saying.
          Perhaps my English is not as good as should be.

          1 Reply Last reply Reply Quote 0
          • A Offline
            alexdobras
            last edited by

            good news, mate:
            i created another dxf with text and saved as Ascii 2010 drawing dxf
            and guess what ? it has imported almost perfectly, if the cyan letters weren't reshaped:

            here's the file:text2010.dxf
            here's the preview in CAD:1.PNG
            here's the peview in SU:2.PNG

            seems when importing into SU, it is not recognized the shape of the cyan text 😐

            the same exact thing happens with a 2004 dxf ,with the cyan text

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              Alex...
              When you give a DXF [or DWG] to someone you need to tell them what units it was made with.
              Sketchup always uses inches as its base units - the displayed units are simply to help users who work in say 'cm'...
              CAD programs typically just work in an arbitrary 'unit'.
              When you are working in the file you assume that say 1 unit = 1 cm.
              When you give that CAD file to someone else unless you tell them the assumed units that were used they have no way of knowing what 1 unit of the CAD file is in the SKP... SO if a line is i unit long how do I know you meant it to be 1m or 1mm, or whatever...

              On the issue of the 'incorrect font'.
              The DXF importer uses a list of typical fonts found on most PCs and MACs.
              A text-font that is not available as a 'tt' font on your system reverts to 'Arial' as here with the 'cyan' text.
              Your DXF only includes ONE STYLE

              0
              STYLE
              5
              11
              330
              3
              100
              AcDbSymbolTableRecord
              100
              AcDbTextStyleTableRecord
              2
              Standard
              70
              0
              40
              0.0
              41
              1.0
              50
              0.0
              71
              0
              42
              2.5
              3
              txt
              4

              0
              ENDTAB
              which is named 'Standard' [#2] and uses a font-file called 'txt' [#3] - and there is no 'named' tt-font [no #1000]. It's set at 0.0 high [#40] so the user can specify the text height. It's width-factor is 1.0 [#41]. It's obliqueness is 0.0 [#50]. It is not flipped [#71]. It has no set color [no #62]...
              The cyan colored TEXT that says 'traa aaskjaksdfasdfa' is set in the DXF as follows...
              No STYLE set [no #7] - reverts to the default style of 'Standard'...
              Layer = '0' [#8]
              Thickness = 50 [#39] WHY ???
              Oblique = 30 [#51] WHY ???
              Color = '4' [#62]
              Flipped = 6 [#71] WHY ???
              Rotated = 10 [#50] WHY ???
              If any TEXT has it's values set weirdly like this it will revert to some defaults to at least import something !
              Please use this tool as it is intended... Sketchup importers will only bring in raw geometry and ignore text etc. I made this tool to bring in text from a DXF... BUT there are limits - it did bring in all of the text even if some of it had been cruelly 'mangled' by you before hand πŸ˜’

              TIG

              1 Reply Last reply Reply Quote 0
              • A Offline
                alexdobras
                last edited by

                thanks TIG for the complete description.
                i just wanted to dream about how cool it would have been if the text was completely imported with all the characteristics. but never the less,at least everything is imported and even has color.
                so, thanks a tonne for making this possible, TIG, you rock!

                1 Reply Last reply Reply Quote 0
                • W Offline
                  Wakanai77
                  last edited by

                  This worked for me and saved alot of time!

                  thank you very much

                  1 Reply Last reply Reply Quote 0
                  • Miner_JeffM Offline
                    Miner_Jeff
                    last edited by

                    Hello,

                    I realize this is a an old thread. Anyone else having issues trying to use this with Sketchup make 2015?
                    I get a crash shortly after invoking the script in the console, goes straight to bugsplat reporting.

                    Thanks Tig for all your selflessness in sharing of your ruby programming skills.

                    Cheers,

                    Miner_jeff

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      Can you shared the text's DXF with me ?
                      You can PM it to me if needed.

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • TIGT Offline
                        TIG Moderator
                        last edited by

                        Having looked at the DXF you PM'd to me...
                        I confirm that it contains NO TEXT/MTEXT entities, unlike a normal CAD-originated DXF might.
                        There seems to very little I might call 'text' ["...FILM..."], and there are many empty objects that look like they might have been intended to be text...

                        I suspect that everything is in CAD 'lines' or 'polylines', and that no CAD 'text' is included in it - perhaps because of the preprocessing app you've used ?

                        TIG

                        1 Reply Last reply Reply Quote 0
                        • Miner_JeffM Offline
                          Miner_Jeff
                          last edited by

                          Hi Tig,

                          You are correct. I will have to investigate Inkscape a little further as to why no text objects are being saved with the saveas DXF export.

                          Do you get a bug splat if you attempt to use importDXFtext and there are no text entities in the DXF?

                          Cheers,

                          Miner_jeff

                          1 Reply Last reply Reply Quote 0
                          • TIGT Offline
                            TIG Moderator
                            last edited by

                            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
                            • TommyKT Offline
                              TommyK
                              last edited by

                              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
                              • TIGT Offline
                                TIG Moderator
                                last edited by

                                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
                                • TommyKT Offline
                                  TommyK
                                  last edited by

                                  Ah, understood. My apologies.

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    daniele.capuccini
                                    last edited by

                                    Is it compatible with SketchUp 2016?
                                    Thanks

                                    1 Reply Last reply Reply Quote 0
                                    • TIGT Offline
                                      TIG Moderator
                                      last edited by

                                      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
                                      • TommyKT Offline
                                        TommyK
                                        last edited by

                                        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
                                        • cmeedC Offline
                                          cmeed
                                          last edited by

                                          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
                                          • TIGT Offline
                                            TIG Moderator
                                            last edited by

                                            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
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 8
                                            • 9
                                            • 2 / 9
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement