Apr 30, 2012

Join the separated lines of 3D/CAD data


Recently I received a mail from the owner of the site ADi Kiteboarding.
He said that he wanted to edit the data exported from 3D application, but the lines are separated and couldn't be connected each other properly even he used my script "Join Reasonably.js".

I'd heard sometimes that some people were also using "Join..." script to join the lines the data of 3D/CAD application.  So I tried to write one to be able to join the lines like this kind of data.  This time I post this one with the agreement of Adi.

Received data was like the above image(left).  It was constructed from the paths like the above image(right).   Some part of the paths were overlapped.  So complicated.

It seemed that connecting from point to point needed a complex algorithm.
So I decided to use the segment ( the line between 2 anchors ) as a unit.
The script breaks all the paths into segments and removes overlapped segments.  Then it connects the segments if its end points are closer than the threshold (0.1mm).  If there's no more near point, it creates another path from the rest of paths.

As a preparation, like the red line of the above image(left), connect the points that too far away, and delete the branched lines.   Then select all the paths you want to connect, and run the script.  The overlapped paths and the isolated points are deleted by the script.

Edit the settings in the script if needed.

As a specification for now, like the above image(right), the script cannot work as you expect in the case that only lines are overlapped and points are not.

download: join_reasonably_2.zip -> http://shspage.com/ex/files.html


Tested with Adobe Illustrator CS5 15.0.2 / Windows XP SP3
This is a beta software. Please use it carefully, at your own risk.



3 comments:

  1. Hi Hiroyuki,
    didn´t know how to contact you so I answer on this post. I´m not able to use the "hearts.js" script with Illustrator CS5 on a Win7 PC.
    I always get this error note:
    "ReferenceError: "segments" is not defined.
    at Scriptographer Scripts\hearts.js:98
    at Scriptographer Scripts\hearts.js:76"
    What am I doing wrong?

    Kind regards,

    Philipp (philipok@hotmail.com)

    ReplyDelete
    Replies
    1. Hi Philipp,
      Thank you for the report. It was a bug.
      I fixed and uploaded it.
      I'll rewrite other scripts to work with latest Sg in the near future.
      Thanks,

      Delete
  2. O, thank gods and you personally for this script! I had similar tasks months and years ago and I wish so much you have done it those days.. and I hope it will work flawlessly at new tasks.

    ReplyDelete

Note: Only a member of this blog may post a comment.