22 Aug 2018

Comparing AutoCAD Drawings with Forge Design Automation -2

AutoCAD Drawing Compare

A sample workflow of application

This post is a continuation to my earlier post

This sample uses AWS S3 storage to host client files and initiates forge design automation to compare two AutoCAD drawings, results the output drawing back to client, the output drawing contains visual graphical difference.

Set up AWS S3 , the uploaded files are public readable, look at the 'acl' object.

const uploadToAws = multer({
    storage: multerS3({
        s3: s3,
        acl: 'public-read',
        bucket: config.credentials.aws_bucketname,
        key: function (req, file, cb) {
            cb(null, file.originalname); //use Date.now() for unique file keys


Processing upload files to S3.

app.post('/upload', uploadToAws.array('upl1', 2), (req, res, next) => {
        res.on('finish', () => {
        console.log('response sent');
    if (typeof req.files !== 'undefined' && req.files.length > 0) {
        dwgFiles.dwg1 = req.files[0].location;
        dwgFiles.dwg2 = req.files[1].location;        

Once the files are uploaded to S3, pass them on to Forge Design Automation

        .then(function (credentials) {
            submitWorkItem(dwgFiles, oAuth2TwoLegged, credentials)
            .then(function (workItemResp){
                console.log("*** workitem post response:", workItemResp.body);
                var workItemId = workItemResp.body.Id;
                res.json({ success: true, message: 'Submitted WorkItem Successfully!', workItemId: workItemId });
            .catch(function (error){
                res.json({ success: false, message: 'Submitted WorkItem Failed!' });
                res.status (500).end () ;
            res.status(500).end() ;

Full sample is available on github and see live demo 

Related Article