Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Copy Objects from Paper Space to Model Space

6 REPLIES 6
Reply
Message 1 of 7
JC_BL
3439 Views, 6 Replies

Copy Objects from Paper Space to Model Space

Sorry for the long post.

 

I am trying to find a way to copy some polylines that are placed on paper-space to the corresponding location in model-space.  But I am having a trouble doing this because the paper-space and model-space are in two different drawings.  Let me explain:

  1. Our program calls an AutoLISP script to generate a DWG file from the paper-space of a drawing using EXPORTLAYOUT command.
  2. Our program uploads the DWG file to AutoCAD-360 where field workers can add polylines on the DWG file to mark the pieces on the DWG.
  3. Our program downlods the DWG file (with polylines from our field workers).  And it tries to figure out how to copy and paste the polylines from the DWG file (that was made from paper-space) to the corresponding location in model-space of the original drawing.  That's where I hit the wall.

Please note that the whole process is done at night automatically when no one around.  This means this is a batch-processing, not an interactive-processing.

 

Previously I have solved this problem by adding a reference point in the WCS (0,0,0) in the model space and making sure that the reference point is also showing up in the paper-space.  Then the program can use the reference point when it copies and pastes the whole block of polylines from paper-space drawing to the model space of the original drawing.  This works very well for most of our drawings.  Unfortunately, there are some drawings that we cannot use this method for some reason that is specific to how our company works.  For those drawings, we must use paper-space that has a viewport that is zoomed into an area in the drawing.  The consequence is that we don't have a paper-space that includes WCS (0,0,0) as the reference point.  Without the reference point, I don't know how to position the polylines from paper-space DWG to model-space of the origianl drawing.

 

So far, I have draw a box around the viewport in paper-space, and find out the XY coordinates of the 4 corners of the box in both paper-space coordinates and the corresponding model-space coordinates.  I can capture this info when our program generates the DWG file from the paper-space, and save this info into a text file somewhere -- that is in the Step-1 above.  And then retrieve that info in Step-3 above.  But I don't seem to be able to use this info for positioning the polylines.  Does anyone have a way to use that info to position the polylines.  Does anyone have an alternative to accomplish this?

 

Please let me know.  Thanks in advance.

 

Jay Chan

6 REPLIES 6
Message 2 of 7
JC_BL
in reply to: JC_BL

I "believe" I can add a reference point in paper space DWG by doing these:

  • First add two lines within the viewport of the paper-space.  The intersection of those two lines is the WCS (0,0,0) in the model space.
  • The DWG generated from the paper-space will have those two lines in it.  Those two lines will point to the reference point inside the paper-space DWG.  Then I can correctly position the polylines to the original drawing using the reference point.


This is the idea.  Now the hard part is to find a way to tell which two lines in the paper-space is for which viewport because the paper-space has multiple viewports.  If there are 4 viewports, the DWG from paper-space will have 4 pairs of lines.  So far I am not sure how I can tell which pair are for which viewport.  Oh well...

Message 3 of 7
hmsilva
in reply to: JC_BL


@jchan wrote:

...

 Now the hard part is to find a way to tell which two lines in the paper-space is for which viewport because the paper-space has multiple viewports.  If there are 4 viewports, the DWG from paper-space will have 4 pairs of lines.  So far I am not sure how I can tell which pair are for which viewport.  Oh well...


Hi jchan,

 

Perhaps using XDATA...

 

Henrique

EESignature

Message 4 of 7
JC_BL
in reply to: hmsilva

Thanks for the suggestion of using XDATA.  But I think I need to change my approach.

 

I find that I have been thinking about this for too long, and focus on only one solution.  Now I step back and think about this.  I think there is a much easier way.  All I need to do is to add a point or circle in WCS (0,0,0), switch to a viewport in the paper-space layout tab, use CHSPACE command to figure out the paper-space coordinates of that point or circle, and then I can save that paper-space coordinates into a text file.  When I need to copy and paste polylines for one viewport from a paper-space DWG file, I will open that text file to find out the paper-space coordinates of that point or circle cooresponding to that viewport.  And I will be able to position the polylines to the correct location in model space.

 

Seem like I hadn't been thinking straight for the last few days.

 

Jay Chan

Message 5 of 7
hmsilva
in reply to: JC_BL


@jchan wrote:

Thanks for the suggestion of using XDATA.  But I think I need to change my approach.

 

I find that I have been thinking about this for too long, and focus on only one solution.  Now I step back and think about this.  I think there is a much easier way.  All I need to do is to add a point or circle in WCS (0,0,0), switch to a viewport in the paper-space layout tab, use CHSPACE command to figure out the paper-space coordinates of that point or circle, and then I can save that paper-space coordinates into a text file.  When I need to copy and paste polylines for one viewport from a paper-space DWG file, I will open that text file to find out the paper-space coordinates of that point or circle cooresponding to that viewport.  And I will be able to position the polylines to the correct location in model space.


Hi Jay Chan,

 

when I suggested the use of  XDATA It was only to avoid adding new objects to the dwg...

 

Henrique

EESignature

Message 6 of 7
greg_battin
in reply to: JC_BL

Alan created this beauty a while back http://www.cadtutor.net/forum/showthread.php?63256-Paper-and-Modelspace&p=431445&viewfull=1#post4314...

 

I keep this in my "Drafting Helpers" and here are some icons if anyone else wants to use them as well.

 

~Greg

Message 7 of 7
Lee_Mac
in reply to: greg_battin

Alan's code could be shortened slightly, as there's no need to compile a new selection set of the copied objects - the program can simply supply the CHSPACE command with the original selection, and leave the copies in place, e.g.:

 

(defun c:cchspace ( / i s )
    (if (setq s (ssget "_:L"))
        (progn
            (repeat (setq i (sslength s))
                (vla-copy (vlax-ename->vla-object (ssname s (setq i (1- i)))))
            )
            (vl-cmdf "_.chspace" s "")
        )
    )
    (princ)
)
(vl-load-com) (princ)

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost