Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

How can I create a simple Autocad drawing with Perl

by Lotus1 (Vicar)
on Sep 29, 2019 at 15:16 UTC ( #11106839=perlquestion: print w/replies, xml ) Need Help??

Lotus1 has asked for the wisdom of the Perl Monks concerning the following question:

Edit: I apologize for not making the OP clearer. I tried to show the steps I took but should have put my question and a short explanation at the top of such a long post. I added bold text above. I'll be using Inkscape to solve my immediate problem so this thread can just be ignored unless anyone is interested in creating CAD documents with Perl.

I would like to write a script to create some simple 2D Autocad drawings and save to DXF or .dwg format. I found a module, CAD::Drawing, that seems seemed to do exactly that but I'm having trouble installing it installing it is a waste of time since the module has been broken for 5 years and the openDWG toolkit needed to create DWG/DXF files is not available. The first complaint from the build was that ImageMagick was missing. After struggling to get the correct version of the Imagemagick binaries installed correctly on Windows I found out about Strawberry Perl's PPM command and I was able to quickly install an ImageMagick bundle.

The required Stream module has been broken for years and the author has died.The next roadblock was a module called Stream::FileInputStream. This module won't install on Strawberry Perl 5.30 64 bit due to changes in the POSIX module. They have removed the POSIX::tmpnam() function and given a note that people should use File::Temp instead.

I was able to get Stream to install (but it is irrelevant) by patching the lines in c:\strawberry\cpan\build\Stream-1.00-1\test.pl that used POSIX::tmpnam(). In package main I added use File::Temp qw/ :POSIX /;.

package main; use Stream::IO; use POSIX; use Carp; use File::Temp qw/ :POSIX /;

Then in both places where POSIX::tmpnam() is used I replaced it with just tmpnam().

#my $tmpfile = POSIX::tmpnam(); my $tmpfile = tmpnam();

After that I could do gmake test and gmake install from the command prompt in c:\strawberry\cpan\build\Stream-1.00-1.

When I tried again to install CAD::Drawing there were lots of errors as shown below. After all this work I discovered that the standard installation for CAD::Drawing doesn't include the IO modules needed to create Autocad output files. You are required to download the OpenDWG toolkit seperately. The POD for CAD::Drawing does not mention the missing tools. The examples show writing to DXF output files but don't mention the dependancy until you read the POD for CAD::Drawing::IO::OpenDWG.

The POD for CAD::Drawing::IO::OpenDWG says "CAD::Drawing::IO::OpenDWG - Accessor methods for OpenDWG toolkit wrapper"

I found that the toolkit is no longer opensource at https://www.opendesign.com/pricing. It appears that there is an old open source version still available at https://sourceforge.net/projects/opendwg/ but it appears to me that it needs to be built from C/C++.

There is a GNU project called LibreDWG that is intended to recreate this library but CAD::Drawing has not been updated in many years. I don't know if LibreDWG would be a drop-in replacement for OpenDWG.

I'm considering trying to take over maintenance of this module in order to update the documentation and add a request for someone to update the module to use the new GNU toolkit. The Stream module hasn't been updated since 1996 and the author seems to have died from what I could find out about him in a web search. The Stream module could use some updates as well.

I found a Python module called dxfwrite that seems to be a pure Python solution that doesn't need external applications such as Image Magick. It doesn't have all the advanced features the CAD::Drawing provides but it can create basic drawings. 'dxfwrite' seems like it would be simple to port to Perl. If I understood Python (and Perl) better I would try it. If a good Perl hacker would set up a Perl skeleton with stubs for the various Python files to be converted I bet a lot of us could contribute by converting the Python files into the Perl stubs.

For my CAD project I'll likely just create SVG drawings with Perl and then call Inkscape to convert them to DXF. I haven't tested that yet so if I can't get that working I'll likely use the Python module and put my budding Python skills to work.

Does anyone have suggestions on how to create basic Autocad files from Perl?

Here is the CPAN output of the CAD::Drawing build after installing ImageMagic and the Stream modules:

Loading internal logger. Log::Log4perl recommended for better logging CPAN: CPAN::SQLite loaded ok (v0.217) Database was generated on Mon, 23 Sep 2019 03:48:59 GMT Running install for module 'CAD::Drawing' CPAN: Digest::SHA loaded ok (v6.02) CPAN: Compress::Zlib loaded ok (v2.086) Checksum for C:\STRAWB~1\cpan\sources\authors\id\E\EW\EWILHELM\CAD-Dra +wing-0.26.tar.gz ok CPAN: Archive::Tar loaded ok (v2.32) CPAN: YAML::XS loaded ok (v0.78) CPAN: CPAN::Meta::Requirements loaded ok (v2.140) CPAN: Parse::CPAN::Meta loaded ok (v2.150010) CPAN: CPAN::Meta loaded ok (v2.150010) CPAN: Module::Build loaded ok (v0.4229) Configuring E/EW/EWILHELM/CAD-Drawing-0.26.tar.gz with Build.PL Created MYMETA.yml and MYMETA.json Creating new 'Build' script for 'CAD-Drawing' version '0.26' EWILHELM/CAD-Drawing-0.26.tar.gz C:\Strawberry\perl\bin\perl.exe Build.PL -- OK Running Build for E/EW/EWILHELM/CAD-Drawing-0.26.tar.gz CPAN: Module::CoreList loaded ok (v5.20190522) Building CAD-Drawing EWILHELM/CAD-Drawing-0.26.tar.gz C:\Strawberry\perl\bin\perl.exe ./Build -- OK Running Build test for EWILHELM/CAD-Drawing-0.26.tar.gz "my" variable $action masks earlier declaration in same statement at C +:\STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm l +ine 292. "my" variable $type masks earlier declaration in same statement at C:\ +STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm lin +e 294. "my" variable $action masks earlier declaration in same scope at C:\ST +RAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line +295. "my" variable $type masks earlier declaration in same scope at C:\STRA +WB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 29 +5. "my" variable $useful masks earlier declaration in same scope at C:\ST +RAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line +296. "my" variable %handlers masks earlier declaration in same scope at C:\ +STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm lin +e 297. "my" variable $action masks earlier declaration in same scope at C:\ST +RAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line +297. "my" variable $type masks earlier declaration in same scope at C:\STRA +WB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 29 +7. "my" variable $mod masks earlier declaration in same scope at C:\STRAW +B~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 297 +. "my" variable $action masks earlier declaration in same statement at C +:\STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm l +ine 297. "my" variable $type masks earlier declaration in same scope at C:\STRA +WB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 29 +8. "my" variable $mod masks earlier declaration in same scope at C:\STRAW +B~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 298 +. "my" variable $action masks earlier declaration in same scope at C:\ST +RAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line +300. "my" variable $type masks earlier declaration in same scope at C:\STRA +WB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 30 +0. "my" variable $mod masks earlier declaration in same scope at C:\STRAW +B~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 300 +. "my" variable $plgindbg masks earlier declaration in same scope at C:\ +STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm lin +e 301. "my" variable %handlers masks earlier declaration in same scope at C:\ +STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm lin +e 302. "my" variable $action masks earlier declaration in same scope at C:\ST +RAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line +302. "my" variable $type masks earlier declaration in same scope at C:\STRA +WB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 30 +2. # Failed test 'use CAD::Drawing;' # at t\00-load.t line 4. # Tried to use 'CAD::Drawing'. # Error: syntax error at C:\STRAWB~1\cpan\build\CAD-Drawing-0.26- +0\blib\lib/CAD/Drawing/IO.pm line 290, near "$action qw(load save)" # syntax error at C:\STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/C +AD/Drawing/IO.pm line 310, near "else" # BEGIN not safe after errors--compilation aborted at C:\STRAWB~1\cpan +\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 312. # Compilation failed in require at C:\STRAWB~1\cpan\build\CAD-Drawing- +0.26-0\blib\lib/CAD/Drawing.pm line 11. # BEGIN failed--compilation aborted at C:\STRAWB~1\cpan\build\CAD-Draw +ing-0.26-0\blib\lib/CAD/Drawing.pm line 11. # Compilation failed in require at t\00-load.t line 4. # BEGIN failed--compilation aborted at t\00-load.t line 4. # Failed test 'use CAD::Drawing::IO;' # at t\00-load.t line 6. # Tried to use 'CAD::Drawing::IO'. # Error: Attempt to reload CAD/Drawing/IO.pm aborted. # Compilation failed in require at t\00-load.t line 6. # BEGIN failed--compilation aborted at t\00-load.t line 6. # Failed test 'use CAD::Drawing::IO::Compressed;' # at t\00-load.t line 9. # Tried to use 'CAD::Drawing::IO::Compressed'. # Error: Attempt to reload CAD/Drawing.pm aborted. # Compilation failed in require at C:\STRAWB~1\cpan\build\CAD-Drawing- +0.26-0\blib\lib/CAD/Drawing/IO/Compressed.pm line 4. # BEGIN failed--compilation aborted at C:\STRAWB~1\cpan\build\CAD-Draw +ing-0.26-0\blib\lib/CAD/Drawing/IO/Compressed.pm line 4. # Compilation failed in require at t\00-load.t line 9. # BEGIN failed--compilation aborted at t\00-load.t line 9. # Failed test 'use CAD::Drawing::IO::FlatYAML;' # at t\00-load.t line 10. # Tried to use 'CAD::Drawing::IO::FlatYAML'. # Error: Attempt to reload CAD/Drawing.pm aborted. # Compilation failed in require at C:\STRAWB~1\cpan\build\CAD-Drawing- +0.26-0\blib\lib/CAD/Drawing/IO/FlatYAML.pm line 4. # BEGIN failed--compilation aborted at C:\STRAWB~1\cpan\build\CAD-Draw +ing-0.26-0\blib\lib/CAD/Drawing/IO/FlatYAML.pm line 4. # Compilation failed in require at t\00-load.t line 10. # BEGIN failed--compilation aborted at t\00-load.t line 10. # Failed test 'use CAD::Drawing::IO::Split;' # at t\00-load.t line 11. # Tried to use 'CAD::Drawing::IO::Split'. # Error: Attempt to reload CAD/Drawing.pm aborted. # Compilation failed in require at C:\STRAWB~1\cpan\build\CAD-Drawing- +0.26-0\blib\lib/CAD/Drawing/IO/Split.pm line 4. # BEGIN failed--compilation aborted at C:\STRAWB~1\cpan\build\CAD-Draw +ing-0.26-0\blib\lib/CAD/Drawing/IO/Split.pm line 4. # Compilation failed in require at t\00-load.t line 11. # BEGIN failed--compilation aborted at t\00-load.t line 11. # Failed test 'use CAD::Drawing::Manipulate::Graphics;' # at t\00-load.t line 14. # Tried to use 'CAD::Drawing::Manipulate::Graphics'. # Error: Attempt to reload CAD/Drawing.pm aborted. # Compilation failed in require at C:\STRAWB~1\cpan\build\CAD-Drawing- +0.26-0\blib\lib/CAD/Drawing/Manipulate/Graphics.pm line 4. # BEGIN failed--compilation aborted at C:\STRAWB~1\cpan\build\CAD-Draw +ing-0.26-0\blib\lib/CAD/Drawing/Manipulate/Graphics.pm line 4. # Compilation failed in require at t\00-load.t line 14. # BEGIN failed--compilation aborted at t\00-load.t line 14. # Testing CAD::Drawing # Looks like you failed 6 tests of 12. t\00-load.t .......... Dubious, test returned 6 (wstat 1536, 0x600) Failed 6/12 subtests t\01-pod-coverage.t .. skipped: Test::Pod::Coverage 1.04 required for +testing POD coverage t\02-pod.t ........... skipped: $ENV{TEST_POD} is not set t\03-prereq.t ........ skipped: Test::Prereq::Build required to test d +ependencies Can't use 'defined(%hash)' (Maybe you should just omit the defined()?) + at t\basic.t line 39. t\basic.t ............ Dubious, test returned 255 (wstat 65280, 0xff00) No subtests run "my" variable $action masks earlier declaration in same statement at C +:\STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm l +ine 292. "my" variable $type masks earlier declaration in same statement at C:\ +STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm lin +e 294. "my" variable $action masks earlier declaration in same scope at C:\ST +RAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line +295. "my" variable $type masks earlier declaration in same scope at C:\STRA +WB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 29 +5. "my" variable $useful masks earlier declaration in same scope at C:\ST +RAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line +296. "my" variable %handlers masks earlier declaration in same scope at C:\ +STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm lin +e 297. "my" variable $action masks earlier declaration in same scope at C:\ST +RAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line +297. "my" variable $type masks earlier declaration in same scope at C:\STRA +WB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 29 +7. "my" variable $mod masks earlier declaration in same scope at C:\STRAW +B~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 297 +. "my" variable $action masks earlier declaration in same statement at C +:\STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm l +ine 297. "my" variable $type masks earlier declaration in same scope at C:\STRA +WB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 29 +8. "my" variable $mod masks earlier declaration in same scope at C:\STRAW +B~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 298 +. "my" variable $action masks earlier declaration in same scope at C:\ST +RAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line +300. "my" variable $type masks earlier declaration in same scope at C:\STRA +WB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 30 +0. "my" variable $mod masks earlier declaration in same scope at C:\STRAW +B~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 300 +. "my" variable $plgindbg masks earlier declaration in same scope at C:\ +STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm lin +e 301. "my" variable %handlers masks earlier declaration in same scope at C:\ +STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm lin +e 302. "my" variable $action masks earlier declaration in same scope at C:\ST +RAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line +302. "my" variable $type masks earlier declaration in same scope at C:\STRA +WB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 30 +2. # Failed test 'use CAD::Drawing;' # at t\methods.t line 16. # Tried to use 'CAD::Drawing'. # Error: syntax error at C:\STRAWB~1\cpan\build\CAD-Drawing-0.26- +0\blib\lib/CAD/Drawing/IO.pm line 290, near "$action qw(load save)" # syntax error at C:\STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/C +AD/Drawing/IO.pm line 310, near "else" # BEGIN not safe after errors--compilation aborted at C:\STRAWB~1\cpan +\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 312. # Compilation failed in require at C:\STRAWB~1\cpan\build\CAD-Drawing- +0.26-0\blib\lib/CAD/Drawing.pm line 11. # BEGIN failed--compilation aborted at C:\STRAWB~1\cpan\build\CAD-Draw +ing-0.26-0\blib\lib/CAD/Drawing.pm line 11. # Compilation failed in require at t\methods.t line 16. # BEGIN failed--compilation aborted at t\methods.t line 16. # Failed test 'CAD::Drawing->Clone' # at t\methods.t line 23. # Failed test 'CAD::Drawing->Copy' # at t\methods.t line 23. # Failed test 'CAD::Drawing->CutPline' # at t\methods.t line 23. # Failed test 'CAD::Drawing->EntOrthExtents' # at t\methods.t line 23. # Failed test 'CAD::Drawing->Get' # at t\methods.t line 23. # Failed test 'CAD::Drawing->GroupClone' # at t\methods.t line 23. # Failed test 'CAD::Drawing->GroupCopy' # at t\methods.t line 23. # Failed test 'CAD::Drawing->GroupMirror' # at t\methods.t line 23. # Failed test 'CAD::Drawing->GroupMove' # at t\methods.t line 23. # Failed test 'CAD::Drawing->GroupRotate' # at t\methods.t line 23. # Failed test 'CAD::Drawing->GroupScale' # at t\methods.t line 23. # Failed test 'CAD::Drawing->IntPline' # at t\methods.t line 23. # Failed test 'CAD::Drawing->Mirror' # at t\methods.t line 23. # Failed test 'CAD::Drawing->Move' # at t\methods.t line 23. # Failed test 'CAD::Drawing->NewMat' # at t\methods.t line 23. # Failed test 'CAD::Drawing->OrthExtents' # at t\methods.t line 23. # Failed test 'CAD::Drawing->Rotate' # at t\methods.t line 23. # Failed test 'CAD::Drawing->Scale' # at t\methods.t line 23. # Failed test 'CAD::Drawing->Set' # at t\methods.t line 23. # Failed test 'CAD::Drawing->Transform' # at t\methods.t line 23. # Failed test 'CAD::Drawing->_ocs_axes' # at t\methods.t line 23. # Failed test 'CAD::Drawing->_wcs_axes' # at t\methods.t line 23. # Failed test 'CAD::Drawing->add_fake_ray' # at t\methods.t line 23. # Failed test 'CAD::Drawing->add_x' # at t\methods.t line 23. # Failed test 'CAD::Drawing->addr_by_color' # at t\methods.t line 23. # Failed test 'CAD::Drawing->addr_by_id' # at t\methods.t line 23. # Failed test 'CAD::Drawing->addr_by_layer' # at t\methods.t line 23. # Failed test 'CAD::Drawing->addr_by_regex' # at t\methods.t line 23. # Failed test 'CAD::Drawing->addr_by_type' # at t\methods.t line 23. # Failed test 'CAD::Drawing->addrec' # at t\methods.t line 23. # Failed test 'CAD::Drawing->addtextlines' # at t\methods.t line 23. # Failed test 'CAD::Drawing->addtexttable' # at t\methods.t line 23. # Failed test 'CAD::Drawing->angle_of' # at t\methods.t line 23. # Failed test 'CAD::Drawing->area' # at t\methods.t line 23. # Failed test 'CAD::Drawing->build_matrix' # at t\methods.t line 23. # Failed test 'CAD::Drawing->can_load' # at t\methods.t line 23. # Failed test 'CAD::Drawing->diskaction' # at t\methods.t line 23. # Failed test 'CAD::Drawing->divide' # at t\methods.t line 23. # Failed test 'CAD::Drawing->drw_to_img' # at t\methods.t line 23. # Failed test 'CAD::Drawing->fit_to_bound' # at t\methods.t line 23. # Failed test 'CAD::Drawing->flatten' # at t\methods.t line 23. # Failed test 'CAD::Drawing->getAddrByColor' # at t\methods.t line 23. # Failed test 'CAD::Drawing->getAddrByLayer' # at t\methods.t line 23. # Failed test 'CAD::Drawing->getAddrByRegex' # at t\methods.t line 23. # Failed test 'CAD::Drawing->getAddrByType' # at t\methods.t line 23. # Failed test 'CAD::Drawing->getEntPoints' # at t\methods.t line 23. # Failed test 'CAD::Drawing->getExtentsRec' # at t\methods.t line 23. # Failed test 'CAD::Drawing->getImgByName' # at t\methods.t line 23. # Failed test 'CAD::Drawing->getLayerList' # at t\methods.t line 23. # Failed test 'CAD::Drawing->get_clip_points' # at t\methods.t line 23. # Failed test 'CAD::Drawing->get_image_rectangle' # at t\methods.t line 23. # Failed test 'CAD::Drawing->get_world_clip_points' # at t\methods.t line 23. # Failed test 'CAD::Drawing->get_world_image_rectangle' # at t\methods.t line 23. # Failed test 'CAD::Drawing->getobj' # at t\methods.t line 23. # Failed test 'CAD::Drawing->img_to_drw' # at t\methods.t line 23. # Failed test 'CAD::Drawing->intersect_pgon' # at t\methods.t line 23. # Failed test 'CAD::Drawing->is_persistent' # at t\methods.t line 23. # Failed test 'CAD::Drawing->list_layers' # at t\methods.t line 23. # Failed test 'CAD::Drawing->load' # at t\methods.t line 23. # Failed test 'CAD::Drawing->new' # at t\methods.t line 23. # Failed test 'CAD::Drawing->offset' # at t\methods.t line 23. # Failed test 'CAD::Drawing->outloop' # at t\methods.t line 23. # Failed test 'CAD::Drawing->place' # at t\methods.t line 23. # Failed test 'CAD::Drawing->pline_to_ray' # at t\methods.t line 23. # Failed test 'CAD::Drawing->pointmirror' # at t\methods.t line 23. # Failed test 'CAD::Drawing->pointrotate' # at t\methods.t line 23. # Failed test 'CAD::Drawing->remove' # at t\methods.t line 23. # Failed test 'CAD::Drawing->rotation_matrices' # at t\methods.t line 23. # Failed test 'CAD::Drawing->save' # at t\methods.t line 23. # Failed test 'CAD::Drawing->scaling_matrix' # at t\methods.t line 23. # Failed test 'CAD::Drawing->select_addr' # at t\methods.t line 23. # Failed test 'CAD::Drawing->setdefaults' # at t\methods.t line 23. # Failed test 'CAD::Drawing->to_ocs' # at t\methods.t line 23. # Failed test 'CAD::Drawing->to_wcs' # at t\methods.t line 23. # Failed test 'CAD::Drawing->transform_pt' # at t\methods.t line 23. # Failed test 'CAD::Drawing->translation_matrix' # at t\methods.t line 23. # Failed test 'CAD::Drawing->trim_both' # at t\methods.t line 23. # Failed test 'use CAD::Drawing::Manipulate::Graphics;' # at t\methods.t line 34. # Tried to use 'CAD::Drawing::Manipulate::Graphics'. # Error: Attempt to reload CAD/Drawing.pm aborted. # Compilation failed in require at C:\STRAWB~1\cpan\build\CAD-Drawing- +0.26-0\blib\lib/CAD/Drawing/Manipulate/Graphics.pm line 4. # BEGIN failed--compilation aborted at C:\STRAWB~1\cpan\build\CAD-Draw +ing-0.26-0\blib\lib/CAD/Drawing/Manipulate/Graphics.pm line 4. # Compilation failed in require at t\methods.t line 34. # BEGIN failed--compilation aborted at t\methods.t line 34. # Failed test '...Graphics::image_crop' # at t\methods.t line 40. # Failed test '...Graphics::image_init' # at t\methods.t line 40. # Failed test '...Graphics::image_rotate' # at t\methods.t line 40. # Failed test '...Graphics::image_scale' # at t\methods.t line 40. # Failed test '...Graphics::image_swap_context' # at t\methods.t line 40. # Looks like you failed 84 tests of 95. t\methods.t .......... Dubious, test returned 84 (wstat 21504, 0x5400) Failed 84/95 subtests Test Summary Report ------------------- t\00-load.t (Wstat: 1536 Tests: 12 Failed: 6) Failed tests: 1, 3, 6-8, 11 Non-zero exit status: 6 t\basic.t (Wstat: 65280 Tests: 0 Failed: 0) Non-zero exit status: 255 Parse errors: No plan found in TAP output t\methods.t (Wstat: 21504 Tests: 95 Failed: 84) Failed tests: 1-25, 32-37, 39-85, 90-95 Non-zero exit status: 84 Files=6, Tests=107, 3 wallclock secs ( 0.08 usr + 0.03 sys = 0.11 C +PU) Result: FAIL Failed 3/6 test programs. 90/107 subtests failed. EWILHELM/CAD-Drawing-0.26.tar.gz C:\Strawberry\perl\bin\perl.exe ./Build test -- NOT OK //hint// to see the cpan-testers results for installing this module, t +ry: reports EWILHELM/CAD-Drawing-0.26.tar.gz Stopping: 'install' failed for 'CAD::Drawing'.

Replies are listed 'Best First'.
Re: How can I create a simple Autocad drawing with Perl
by Corion (Pope) on Sep 29, 2019 at 16:01 UTC

    Line 292 in CAD::Drawing::IO is:

    foreach my $action qw(load save) {

    One of the few changes in Perl syntax now requires parentheses around all lists. The following should be a fix:

    foreach my $action (qw(load save)) {

    You might want to report this as a bug to the author.

      Thanks for working on it. I'm sorry you wasted time on this module with all the other problems there are with it. I stopped debugging the build problems once I realized I couldn't get the openDWG toolkit. I shouldn't have included the build log. The author didn't fix the documentation years ago when people asked him about the dependencies on openDWG so I don't think he is interested in this module anymore.

      One of the few changes in Perl syntax now requires parentheses around all lists.

      When did that happen? Why would p5p give us one less way to do things while breaking an unknown number of CPAN modules? What's the point?

        One of the few changes in Perl syntax now requires parentheses around all lists.
        When did that happen? Why would p5p give us one less way to do things while breaking an unknown number of CPAN modules? What's the point?

        As others explained, it happened more or less in v5.14.0. And the cited statement "now requires parentheses around all lists" is unfortunately wrong.

        To make a long story short, you now have to have parentheses where they were always required by the documentation. A parser bug allowed to omit them sometimes. You don't have to wrap all lists in parentheses. In places like use, parentheses around lists are not required and were never required.

        For the details, read on.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        The point is that occasionally new features of Perl can only be released by restricting old syntax which might result in ambiguous parsing.

        But P5P isn't that careless: All modules undergo regression tests with every version of Perl. The results for CAD::Drawing can be seen here: http://matrix.cpantesters.org/?dist=CAD-Drawing+0.26

        As you see, it is well known that this module fails with all Perls starting from 5.18.2. And since then, as far as I know, the registered maintainer of the CPAN module should have received an email report about the failure.

        Like Corion wrote, the fix is dead simple. So, if you know how to contact the author, it doesn't hurt to nudge him (again). He did the latest release in 2006, but might still be willing to maintain the module.

        This happened in Perl 5.18, so about five years ago. I guess the breakage on CPAN wasn't too bad.

Re: How can I create a simple Autocad drawing with Perl
by holli (Abbot) on Sep 29, 2019 at 15:36 UTC
    syntax error at C:\STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 290
    That's most likely the culprit, the other errors are just consequences of this one. And since this is a syntax error, I'd say it was introduced by your edits. Double check them. Might be something simple like a missing semicolon.


    holli

    You can lead your users to water, but alas, you cannot drown them.

      holli said:

      syntax error at C:\STRAWB~1\cpan\build\CAD-Drawing-0.26-0\blib\lib/CAD/Drawing/IO.pm line 290

      That's most likely the culprit, the other errors are just consequences of this one. And since this is a syntax error, I'd say it was introduced by your edits. Double check them. Might be something simple like a missing semicolon.

      Thanks for having a look. However, I didn't edit anything other than the three lines I mentioned in the test.pl file in the Stream module. If there had been problems with those edits then I wouldn't have expected the Stream install to work after that. I don't see how that test file could affect IO.pm. Even if I could get CAD::Drawing to install it wouldn't work anyway because of the missing openDWG toolkit I mentioned. I suppose I should stop posting such long threads to Perlmonks. I thought the monks would be impressed by the steps I took in debugging the Stream install and digging into the documentation. I didn't want others to waste time debugging this module like I did.

Re: How can I create a simple Autocad drawing with Perl
by NERDVANA (Beadle) on Oct 01, 2019 at 06:41 UTC
    I would suggest using OpenSCAD to generate the dxf, and then generate the code for openscad using perl.

      I've used OpenSCAD quite a bit for 3D design but I had forgotten that it will export to DXF. I don't know how I would write code in Perl to create OpenSCAD code. That would be an interesting project for a new module. I have about 6,000 drawings to create this way daily so it would need to be a general solution.

      I have been planning to create SVG in Perl and then automate converting that to DXF with Inkscape. OpenSCAD might be even better at the SVG to DXF conversion. Thanks for the suggestion.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11106839]
Approved by holli
Front-paged by haukex
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2021-02-26 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?