mozman / ezdxf

Python interface to DXF
https://ezdxf.mozman.at
MIT License
906 stars 189 forks source link

Copy to clipboard failed. #9

Closed mortbauer closed 4 years ago

mortbauer commented 7 years ago

On opening any with ezdxf created drawing in Autocad 2014 and trying to copy something I get: Copy to cliboard failed.

mozman commented 7 years ago

I know and I have no other solution than saving the drawing with AutoCAD as DWG file.

mortbauer commented 7 years ago

It works in dxfwrite though, I opened another issue to clarify the relation of these two libraries.

mozman commented 7 years ago

dxfwrite just writes DXF12 - this is my first dxf package and it is in maintenance mode, no new features will be added.

ezdxf can read/write/modify all DXF versions from DXF12 to DXF R2013, even older DXFs but this feature is not well tested. If I add new features, it will be done in ezdxf.

mortbauer commented 7 years ago

a thank you.

could the problem be related to blocks? because I also can not get proper blocks, when I ran flags.py from the examples folder and run EATTEDIT on a block Autocad Mechanical 2014 will tell me that the selected block does not have any editable attributes, whereas when I run the flags.py example from dxfwrite it again works without any problem.

mozman commented 7 years ago

As I remember this problem also occurs just for simple lines. I don't have an AutoCAD license yet, I just use TrueView and can't verify such errors now. It seems to be a undocumented DXF structure setting which is violated, but AutoCAD does not give any error message about it.

I don't see this as big problem: If you don't use AutoCAD, you don't have this problem, and if you use AutoCAD, just save the file as DWG and the problem is gone.

ghost commented 7 years ago

Hi @mozman , I've been watching this project for a long time (before on BitBucket too). I was reading over the issues and figured I'd check this out with my copy of AutoCAD. After running an audit the copy to clipboard succeeds. Hope this information helps:

Command: audit Fix any errors detected? [Yes/No] : y Auditing Header Auditing Tables Auditing Entities Pass 1 AcDbLayerTableRecord: "0" PlotstyleName Id Invalid Null AcDbLayerTableRecord: "View Port" PlotstyleName Id Invalid Null AcDbLayerTableRecord: "Defpoints" PlotstyleName Id Invalid Null Pass 1 100 objects audited Auditing Entities Pass 2 AcDbBlockTableRecord: "*Model_Space" Extension dictionary 15D Cannot access Removed Pass 2 100 objects audited Auditing Blocks 2 Blocks audited Auditing AcDsRecords Total errors found 4 fixed 4 Erased 0 objects Command:

jgrarod commented 6 years ago

It seems that the problem is in the template "AC105.dxf" file. You need to add the following code:

  0
DICTIONARY
  5
15D
330
1F
100
AcDbDictionary
280
     1
281
     1

after line 2474. Once fixed, the dxf generated works fine with copy/paste operations.

At line 2112 of the template the following code:

{ACAD_XDICTIONARY
360
15D
102
}

points (code 360) to a "Hard-owner ID/handle to owner dictionary" (15D) which is not defined in the template. This dictionary is created adding the previous code to the template.

mozman commented 6 years ago

Hi!

Thank you, but your line numbers do not match with the actual AC1015.dxf template.

The problem is fixed for DXF R2000 (AC1015) and R2004 (AC1018), but starting from R2007 (AC1021) and later the copy/paste problem still exists.

YunbiaoCao commented 6 years ago

@jgrarod It's good to know you got progress on this issue, I have a try on AC1018.dxf, but failed to fix that, so do you know how to get this work on AC1018.dxf, thank you a lot.

ANAT01 commented 6 years ago

AC1015.zip

Name: ezdxf Version: 0.8.8

AC1009 and AC1018 haven't issue but other (checked only AC1015, AC1021, AC1024 in Autocad 2012) have it.

import ezdxf

"""
- AC1009 or R12: AutoCAD R12 (DXF R12)
- AC1015 or R2000: AutoCAD 2000 (DXF R2000)
- AC1018 or R2004: AutoCAD 2004 (DXF R2004)
- AC1021 or R2007: AutoCAD 2007 (DXF R2007)
- AC1024 or R2010: AutoCAD 2010 (DXF R2010)
- AC1027 or R2013: AutoCAD 2013 (DXF R2013)
- AC1032 or R2018: AutoCAD 2018 (DXF R2018)
"""

ffs = ['AC1009', 'AC1015', 'AC1018', 'AC1021', 'AC1024', 'AC1027', 'AC1032']

points = [
    (49.84, 70.62),
    (29.83, 85.60),
    (08.93, 57.50),
    (28.93, 42.49)
]

def createDxf(ff):
    dwg = ezdxf.new(ff)
    layout = dwg.modelspace()
    layout.add_polyline2d(points, dxfattribs={'color': 10, 'closed': 1})
    dwg.saveas("%s.dxf" % ff)

for ff in ffs:
    createDxf(ff)
mozman commented 5 years ago

Now using BricsCAD instead of AutoCAD LT (very compatible and more value for your money) and BricsCAD reported some HEADER var issues ($CMATERIAL, $INTERFEREOBJVS, $INTERFEREVPVS) at the audit process, which I fixed (removed) in the template files.

BricsCAD did not have any problems with copy/paste and I don't have access to AutoCAD anymore, so I can not test if AutoCAD still have problems with copy/paste. I append a DXF R2013 file, maybe someone can test copy/paste with AutoCAD.

all_arrows.zip

jmacura commented 5 years ago

@mozman Hi, I've tested the all_arrows.dxf in AutoCAD Map 3D 2017 and copy/paste operations works just fine (y).

benediktbrandt commented 4 years ago

Hi mozman, this is my first time posting here, so first of all thanks for writing this very useful library!

Unfortunately this issue (Copy to clipboard failed) has re-appeared. I am using ezdxf 0.10.2 and Autocad 2020 and every dxf file that I generate with ezdxf.new(..., setup=True) has this issue. The problem seems to be in the visualstyles since it works fine with ezdxf.new(..., setup=['linetypes', 'styles', 'dimstyles']).

Unfortunately saving as dwg or running audit (even when instructed to fix the errors) doesn't solve the problem. The copy issue persists.

Attached is an example DXF with the issue. The output from audit is:

Command: AUDIT
Fix any errors detected? [Yes/No] <N>:
Auditing Header
Auditing Tables
Auditing Entities Pass 1
Pass 1 100     objects audited
Auditing Entities Pass 2
AcDbDictionary(16)    2dWireframe ePermanentlyErased
AcDbDictionary(16)          Basic ePermanentlyErased
AcDbDictionary(16)       Brighten ePermanentlyErased
AcDbDictionary(16)    ColorChange ePermanentlyErased
AcDbDictionary(16)     Conceptual ePermanentlyErased
AcDbDictionary(16)            Dim ePermanentlyErased
AcDbDictionary(16)   EdgeColorOff ePermanentlyErased
AcDbDictionary(16)    Facepattern ePermanentlyErased
AcDbDictionary(16)           Flat ePermanentlyErased
AcDbDictionary(16)  FlatWithEdges ePermanentlyErased
AcDbDictionary(16)        Gouraud ePermanentlyErased
AcDbDictionary(16)
                 GouraudWithEdges ePermanentlyErased
AcDbDictionary(16)         Hidden ePermanentlyErased
AcDbDictionary(16)      JitterOff ePermanentlyErased
AcDbDictionary(16)    Linepattern ePermanentlyErased
AcDbDictionary(16)       Modeling ePermanentlyErased
AcDbDictionary(16)    OverhangOff ePermanentlyErased
AcDbDictionary(16)      Realistic ePermanentlyErased
AcDbDictionary(16)         Shaded ePermanentlyErased
AcDbDictionary(16)
                Shaded with edges ePermanentlyErased
AcDbDictionary(16) Shades of Gray ePermanentlyErased
AcDbDictionary(16)        Sketchy ePermanentlyErased
AcDbDictionary(16)        Thicken ePermanentlyErased
AcDbDictionary(16)      Wireframe ePermanentlyErased
AcDbDictionary(16)          X-Ray ePermanentlyErased
AcDbDictionary(16)                was not repaired.
Pass 2 100     objects audited
Auditing Blocks
 2       Blocks audited
Auditing AcDsRecords
Total errors found 25 fixed 0
Erased 0 objects

52848_IN_2D_Eng.dxf_ezdxf (7).zip

I am happy to help with testing if need be.

mozman commented 4 years ago

Please upload an simple DXF file created by AutoCAD 2020, so I can compare the VISUALSTYLE entites.

BricsCAD has no problem with copy/paste and TrueView can't copy/paste - hard to test without a AutoCAD license.

mozman commented 4 years ago

Found the problem, DXF was saved as R2000, which does not support/export VISUALSTYLE objects, but maintenance dictionary for visual styles was written with handles to none existing objects.

Will be fixed soon.

mozman commented 4 years ago

published BUGFIX release v0.10.3 on pypi