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

    [Plugin] importDXFtext

    已排程 已置頂 已鎖定 已移動 Plugins
    165 貼文 18 Posters 84.9k 瀏覽 18 Watching
    正在載入更多貼文
    • 從舊到新
    • 從新到舊
    • 最多點贊
    回覆
    • 在新貼文中回覆
    登入後回覆
    此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
    • TIGT 離線
      TIG Moderator
      最後由 編輯

      Thanks for the error report - which only affects the DXF's plain-Text, i.e. not Mtext etc...
      It's fixed.
      Get v3.1 here...
      https://sketchucation.com/pluginstore?pln=importDXFtext
      v3.1 Glitch with plain Text import [bold] fixed, cpoint deletion errors trapped.

      TIG

      1 條回覆 最後回覆 回覆 引用 0
      • F 離線
        faust07
        最後由 編輯

        It works now. Thank you TIG. 👍

        1 條回覆 最後回覆 回覆 引用 0
        • M 離線
          marcoferrario
          最後由 編輯

          I do not know why , but when I try to import mtext ... rotation parameter it is not correct as it's always 0 degree . Probably you can help me to understand where I am mistaken

          1 條回覆 最後回覆 回覆 引用 0
          • TIGT 離線
            TIG Moderator
            最後由 編輯

            This script does its best to interpret a DXF file's text and add a similar group of 2d-3dtext into the model.
            This is because the SketchUp DWG/DWF importer only includes geometry and ignores text objects.

            It's not foolproof - it's an old script and it is unlikely to be changed much now.
            You can of course use Layout to access DWG data directly... including its text.

            Or stop rotating the text in the CAD drawing, or manually fix it in SketchUp after import...

            TIG

            1 條回覆 最後回覆 回覆 引用 0
            • uwesketchU 離線
              uwesketch
              最後由 編輯

              Hi
              I have dxf files with Attribute texts and when importing, then I get an error that the variable cp is not defined.
              I attached a small example in order to easily reproduce the issue.
              Can you fix the error?
              I assume it is the same issue as in Oct 2020 with the Text.

              The ruby console output is:
              ......

              Making 0 TEXT Entities...
              Making 0 MTEXT Entities...
              Making 16 ATTRIBUTE TEXT Entities...
              Error: #<NameError:**undefined local variable or method cp' for TIG::ImportDXFtext:Module**> C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1273:in block in make_atext'
              C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1118:in each' C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1118:in each_with_index'
              C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1118:in make_atext' C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1776:in import'
              C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1799:in new' C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1805:in block in module:ImportDXFtext


              dxf containing only Attribute-Texts

              1 條回覆 最後回覆 回覆 引用 0
              • TIGT 離線
                TIG Moderator
                最後由 編輯

                Thanks for the report.
                It was a simple typo...
                I've fixed it.
                An updated RBZ is now available from the PluginStore...
                https://sketchucation.com/pluginstore?pln=importDXFtext

                TIG

                1 條回覆 最後回覆 回覆 引用 0
                • uwesketchU 離線
                  uwesketch
                  最後由 編輯

                  Thanks for the quick reply.
                  I just downloaded, installed and tried.
                  But I still have the same issue and exact same error message.
                  Looks like a new main prog, but same code file.


                  Making 0 TEXT Entities...
                  Making 0 MTEXT Entities...
                  Making 16 ATTRIBUTE TEXT Entities...
                  Error: #<NameError: undefined local variable or method cp'** for TIG::ImportDXFtext:Module> C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:**1273:in block in make_atext'
                  C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1118:in each' C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1118:in each_with_index'
                  C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1118:in make_atext' C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1776:in import'
                  C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1799:in new' C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1805:in block in module:ImportDXFtext'

                  1 條回覆 最後回覆 回覆 引用 0
                  • TIGT 離線
                    TIG Moderator
                    最後由 編輯

                    And the Extension Manager reports it as the latest version v3.2 ?
                    I'll look at it, but the line it reports the error in should not cause this error...

                    TIG

                    1 條回覆 最後回覆 回覆 引用 0
                    • TIGT 離線
                      TIG Moderator
                      最後由 編輯

                      The good news is I've managed to stop that error.
                      The bad news is that SketchUp now Bugsplats after the import...
                      So some work to do !

                      TIG

                      1 條回覆 最後回覆 回覆 引用 0
                      • TIGT 離線
                        TIG Moderator
                        最後由 編輯

                        I've now traced the Bugsplat - only happens when choosing mm as units - suspect it's because the size of the ext is too small and 1/1000" is SketchUp's tolerance...
                        Testing a trap for this...

                        TIG

                        1 條回覆 最後回覆 回覆 引用 0
                        • TIGT 離線
                          TIG Moderator
                          最後由 編輯

                          Here's v3.3
                          https://sketchucation.com/pluginstore?pln=importDXFtext
                          It now sidesteps the 'cp' error message and also avoids a possible Bugsplat when processing Atxt, if you choose mm [or even cm] as your imported DXF's units the tiny size of any Attribute-text could result in very small geometry that crashes SketchUp, so in that case there's a closing message-box to warn you and the imported Attribute-text's units are assumed to be in inches, just for that DXF text-type...
                          Please test and report back as necessary...

                          TIG

                          1 條回覆 最後回覆 回覆 引用 0
                          • uwesketchU 離線
                            uwesketch
                            最後由 編輯

                            Hi TIG

                            SketchUUp Ext. manger showed 3.2 after install. But I did not see the
                            line with**cp =**gents.add... in the code file.

                            Agree, the fix is to be applied about 10 lines further up than what is reported in the console.

                            I think I also had crashes in Sketchup when working with mm.
                            Cool, you could find a work around!

                            Downloaded and installed version 3.3. So far all good.
                            Will test later today and let you know.

                            1 條回覆 最後回覆 回覆 引用 0
                            • uwesketchU 離線
                              uwesketch
                              最後由 編輯

                              out of curiosity, not saying it is wrong or I would know why 😉
                              Yesterday evening, for testing, I did the same change for make_atext as it stands in make_mtext and then it worked.

                              For ***make_text ***and make_mtext you assigned the variable cp:

                                    if string.tr(' ','').gsub(/\\P/,'')==""
                                      string=""
                                     ***cp = gents.add_cpoint(ORIGIN)***
                                      puts "Empty String = Cpoint"
                                      next
                                      #height=100.mm
                                    end#if
                                    ###
                                    bold=false;italic=false
                                    ###
                                    begin
                                      ###
                                      gents.add_3d_text(string,align,font,bold,italic,height,0.0,0.0,true,thick) if string && string !=""
                                    rescue Exception => ex
                                      puts ex
                                    ensure ### ?
                                    end
                                    next unless gp.valid?
                                    ***cp.erase! if cp && cp.valid?*** # we don't need a cpt inside text??
                              

                              But for make_atext, you commented out the line causing errors:

                                    if string.tr(' ','').gsub(/\\P/,'')==""
                                      string=""
                                      ***gents.add_cpoint(ORIGIN)***
                                      puts "Empty String = Cpoint"
                                      next
                                    end#if
                                    string=string.strip.gsub(/\\P/,"\n")### replace \P with \n
                                    ###
                                    bold=false;italic=false
                                    ###
                                    begin
                                      gents.add_3d_text(string,align,font,bold,italic,height,0.0,0.0,true,thick) if string && string !=""
                                    rescue Exception => ex
                                      puts ex
                                    ensure ### ?
                                    end
                                    next unless gp.valid?
                                   ***#cp.erase! if cp && cp.valid?*** # we don't need a cpt inside text??
                              
                              1 條回覆 最後回覆 回覆 引用 0
                              • TIGT 離線
                                TIG Moderator
                                最後由 編輯

                                It's possible to have an empty text string in ACAD Mtext etc, to trap for it I add a cpoint into the group containing the possible text - to ensure the group isn't prematurely deleted as there's no geometry made - at the end that cpoint is deleted to tidy up.
                                As it isn't needed in the Atxt, putting the # in front of the relevant line fixes the error message.

                                The unrelated splat with tiny text from Atxt when using model-mm is trapped by forcing inches for Atxt height when import units are set to mm/cm...

                                TIG

                                1 條回覆 最後回覆 回覆 引用 0
                                • uwesketchU 離線
                                  uwesketch
                                  最後由 編輯

                                  Ok, Clear, makes sense.

                                  I tested and it turns out, that AText is by a factor of 39 too small (100/2.54).
                                  So if I have a MText or Text at position (x,y,z) = (100mm, 100mm, 0mm) then the MText is imported into SketchUp at the right position, but the AText being at the same position in DXF, ends up in SketchUp at (2.54mm,2.54mm,0mm).
                                  Also the height of the Text is much smaller.

                                  I imported indicating units = meter.

                                  Probably this is the reason why if choosing MilliMeter for import, it crashes, because a few mm divided by 39 is giving a too small text size.

                                  1 條回覆 最後回覆 回覆 引用 0
                                  • TIGT 離線
                                    TIG Moderator
                                    最後由 編輯

                                    So what is the outcome of this ?

                                    Previously, for any type of ACAD text, you could specify a unit mm/cm/m/'/" and a matching factor was applied to the DXF's height/spacing etc [assuming it is initially stored in "].

                                    In the newest version that adjustment still applies to Text & Mtext, but for Atext, where the text-height is often ~0.01", sometimes giving very tiny edges in the flat 3d-text characters, so I forced it to check if the unit is set to mm/cm, and if so it uses the DXF's " values instead...

                                    So how should we fix this ? Forgetting the details of the coding itself... what do we need to check and change/keep... e.g. if it's Atext do we increase the height by x39 ? and them reduce if by the unit-factor ??

                                    TIG

                                    1 條回覆 最後回覆 回覆 引用 0
                                    • uwesketchU 離線
                                      uwesketch
                                      最後由 編輯

                                      I checked again with version 3.2 (where I fixed the variable error by setting "cp = gents.add?...")
                                      using units = meters: All works as expected. The MTexts, Texts and ATexts are all at the correct position and size in SketchUp.

                                      As soon as I import with "unites = mm" (which I think is not correct for this drawing), SketchUp crashes. So nothing new.

                                      Somehow I think the Plugin works fine, just that it causes a crash, if units are choosen too small (user error).

                                      Could we not define, that objects are not imported, if the resulting 3D text height is below a limit?
                                      (I assume it is the too small 3D text size which brings Sketchup 2021 and 2022 to a crash)

                                      In the console or a dialog box, the number of skipped texts could be reported at the end of the import process.

                                      I created in SketchUp a 3D text using the standard menu option:
                                      The height of a 3D Text must be equal or bigger than 0.0254 mm(1/1000 inch). If you enter a smaller value, SketchUp gives an error message, saying the length entered is too small. (Probably Sketchup Team had these crashes as well and now there is a data entry validation)

                                      0.0254mm is the smallest height to create a 3D Text

                                      1 條回覆 最後回覆 回覆 引用 0
                                      • TIGT 離線
                                        TIG Moderator
                                        最後由 編輯

                                        Here's v3.4
                                        https://sketchucation.com/pluginstore?pln=importDXFtext
                                        I've adjusted the code so that it partially reads the DXF file header before your choose the Units.
                                        The resulting default in dialog should usually be accepted.
                                        Now you cannot choose units less than the DXF's - which are often in inches - and if you try you are blocked.
                                        However, you can choose units that are bigger, BUT you are warned about the discrepency Y|N...

                                        TIG

                                        1 條回覆 最後回覆 回覆 引用 0
                                        • uwesketchU 離線
                                          uwesketch
                                          最後由 編輯

                                          Thanks.
                                          Tested version 3.4, with the same dxf file as before: unfortunately 😞

                                          I do not even get the unit dialog:
                                          Error: #<TypeError: wrong argument type nil (expected Array)>
                                          C:/Program Files/SketchUp/SketchUp 2022/Tools/sketchup.rb:121:**in inputbox'** C:/Program Files/SketchUp/SketchUp 2022/Tools/sketchup.rb:121:in inputbox'
                                          C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:99:in get_units' C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1880:in new'
                                          C:/Users/Birgit/AppData/Roaming/SketchUp/SketchUp 2022/SketchUp/Plugins/importDXFtext/importDXFtext_code.rb:1894:in `block in module:ImportDXFtext'

                                          1 條回覆 最後回覆 回覆 引用 0
                                          • TIGT 離線
                                            TIG Moderator
                                            最後由 編輯

                                            Aaargh !
                                            I'll republish the version asap...

                                            TIG

                                            1 條回覆 最後回覆 回覆 引用 0
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 6
                                            • 7
                                            • 8
                                            • 9
                                            • 4 / 9
                                            • 第一個貼文
                                              最後的貼文
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement