I would like to know the way to correctly copy and paste selected polylines from one drawing onto the same spot of a sister drawing.
I am trying to do the following using AutoLISP:
Everything works _except_ the copying and pasting of the polylines. I find that the polylines copied to the master drawing become very tiny and they are placed in the wrong place. Seem like the origins / scales of the master drawing and the compressed drawing are different.
How do I find which origin and which scale the master drawing uses?
How do I change the compressed drawing to match the origin and the scale of the master drawing?
Please help me with these. Thanks in advance for your help.
Jay Chan
Solved! Go to Solution.
Solved by GTVic. Go to Solution.
Hello hmsilva,
I don't see anything different with the small DWG file (generated from EXPORTLAYOUT) after following the steps described in your message. The small DWG is still in paper space scale and its (0,0,0) coordinates are still off.
Yes, I can see the reference points (the text "llpt" and "urpt") that "demo" has added near the UCS. And they show up in both the master drawing and the small DWG, and they are in the correct layer "MyAlign".
May be the problem has to do with those two variables msllpt" and "msurpt" in demo1 are not defined?
By the way, I need to add the command (vl-load-com) in both demo and demo1 to get them running. But that doesn't affect the outcome.
Anyway, I will read your program to see if I can pickup something from it.
Jay Chan
@jchan wrote:
Hello hmsilva,
I don't see anything different with the small DWG file (generated from EXPORTLAYOUT) after following the steps described in your message. The small DWG is still in paper space scale and its (0,0,0) coordinates are still off.
Yes, I can see the reference points (the text "llpt" and "urpt") that "demo" has added near the UCS. And they show up in both the master drawing and the small DWG, and they are in the correct layer "MyAlign".
May be the problem has to do with those two variables msllpt" and "msurpt" in demo1 are not defined?
By the way, I need to add the command (vl-load-com) in both demo and demo1 to get them running. But that doesn't affect the outcome.
Anyway, I will read your program to see if I can pickup something from it.
Jay Chan
Hi Jay,
the "msllpt" and "msurpt" are defined in the first code, and were propagated with the vl-propagate function, if you open the small dwg after run the demo, should work as expected.
The vl-load-com my bad, I have the Visual LISP extensions always loaded....sorry
Henrique
I check both msllpt and msurpt variables in the master drawing and the small DWG, they both are nil in both drawngs.
I have tried to debug "demo" and found that the variables psllpt and psurpt have coordinates in them (such as (1.04642 0.796417 0.0) and (9.41775 7.16775 0.0)). But msllpt and msurpt variables are both nil. I manually enter the following command at command prompt, and I find that the return value is nil:
(trans '(9.41775 7.16775 0.0) 3 2)
Seem like that command only works in layout tab. It doesn't work in model space.
Jay Chan
Thanks for pointing out that the first part of the demo program needs to run in the Layout tab.
I still need to make one fix in order for the demo1 to run: I need to remove msllpt and msurpt from the variable definition of demo1, like this:
Before:
(defun demo1 (/ LL MSLLPT MSURPT UR)
After:
(defun demo1 (/ LL UR)
Somehow, the local definition of those two variables hides the variables from (vl-propagate).
Now, I can run demo1 to stretch the objects in the small DWG to exactly the same size as the corresponding objects in the master drawing. This is good. However, there is still one problem. The objects are placed too far left and low. The (0,0,0) in the master drawing becomes (-36.* Ft,-10.* Ft, 0) in the small DWG.
Jay Chan
The (0,0,0) that I was referring to is the UCS of the master drawing. And the UCS and WCS are the same in that drawing.
The lower left corner of the Layout tab of the master drawing is (0,0,0), and the layout is paper space and is the size of a letter size paper.
That (-36.* Ft, -10.* Ft, 0) difference in coordinates doesn't seem to correlate to anything in the master drawing or the small DWG.
Jay Chan
Jay,
I can't reproduce that behavior...
Are you setting OSMODE to zero, before run the demo1?
A simple test, try the code with the attached dwg.
Henrique
Yes, I have used the following command to set OSMODE to zero:
(setvar "OSMODE" 0)
I have tested with your base_layout1.dwg file. The program works fine -- meaning that the scale and coordinates of the small DWG match the master drawing (after the small DWG is stretched with demo1). The result is like this:
The reference line that is in the lower left corner of the master drawing (base_layout1.dwg) is
from (2.0811,0.8311,0.0000) to (3.0488,1.8149,0.0000).
The same reference line in the small DWG before being stretched is
from (2.0554,0.9401,0.0000) to (2.9567,1.8619,0.0000).
The same reference line in the small DWG before after the drawing was stretched using demo1 is
from (2.0811,0.8311,0.0000) to (3.0488,1.8149,0.0000) that is the same as the one in the master drawing.
The only thing different is that those two texts "llpt" and "urpt" are really BIG in my drawing, but are reasonably small in your drawing.
Seem like there is something in my drawing that doesn't work well with your program.
Jay Chan
Jay
make a copy of one of yours master dwg's, erase everything, purge, draw a few lines and post the dwg.
Henrique
Attached please find a trimmed down version of the original master drawing. You can see a small reference point (a circle) right at the UCS, and two polylines in the lower left corner away from the UCS - one pink one blue.
I have tested this drawing with your program, and I still have the exact same problem with this drawing.
Thanks in advance if you can find out what is causing the problem.
Jay Chan
Hi Jay,
the problem was with the TARGET SysVar, to avoid this, try the attached code
(defun c:demo ( / LL MSLLPT MSURPT PSLLPT PSURPT UR VLAOBJ VP) (if (setq vp (ssget "x" '((0 . "viewport") (-4 . "/=") (69 . 1)))) (progn (setq VlaObj (vlax-ename->vla-object (ssname vp 0))) (vla-put-target VlaObj (vlax-3d-point '(0 0 0))) (vlax-invoke-method VlaObj 'GetBoundingBox 'll 'ur) (setq psllpt (vlax-safearray->list ll) psurpt (vlax-safearray->list ur) msllpt (trans psllpt 3 2) msurpt (trans psurpt 3 2) ) (vl-propagate 'msllpt) (vl-propagate 'msurpt) (entmake (list (cons 0 "TEXT") (cons 100 "AcDbText") (cons 8 "MyAlign") (cons 10 psllpt) (cons 40 (getvar 'TEXTSIZE)) (cons 1 "llpt") (cons 100 "AcDbText") ) ) (entmake (list (cons 0 "TEXT") (cons 100 "AcDbEntity") (cons 8 "MyAlign") (cons 10 psurpt) (cons 40 (getvar 'TEXTSIZE)) (cons 1 "urpt") (cons 100 "AcDbText") ) ) ) ) (princ) )
HTH
Henrique
The script works very good now.
What I have learnt from your program are:
1. The way to get access to the viewport of a layout tab.
2. I can use (vl-propagate) to save the info from the master drawing session to the small DWG session. Then I don't need to store the info (such as the scale-up factor) into a text file.
3. The way to create an entity directly into a drawing (as a reference point) using (entmake).
4. Finally the command ALIGN that use two objects as reference points to align everything in the drawing - that can correct the scale and the coordinates all at once.
Thanks for your help.
Jay Chan