Jump to content

Recommended Posts

Posted

Hi,

 

I'm looking for a way to copy only circles (but several of them) from the model space to paper space.

 

 

I found a utility that does it but there are few limitation that need to be resolved.

  1. Can the viewport scale be counted as a part of the routine so that the object seen from the layout space is exactly copied as is (should not come 1:1 if the viewport scale is 1:2) and at the exact same location.
  2. I want to copy only circles of the balloon which is actually an attribute block so something like ncopy (which actually extracts only selected entity out of the whole block). This will actually make 2 overlapping entities but one on the paper space and the other one on the model space.
  3. Now, all this I want to do it from the paper space (without having to go to model space) so that I can pick which entities that I want to copy from layout mode as if I have double clicked inside a viewport which jumps into model space and comes back to PS after the selection is done.

 
(Defun c:Ms2Ps ()
(setq CRT (getvar "Tilemode"))
(setvar "Tilemode" 1)              ; Change to modelspace
(prompt "\nSelect objects to copy to model space: ")
(setq SS1 (ssget))
(command "_.copybase" "0,0" SS1 "")
(setvar "Tilemode" 0)              ;Change to paperspace
(command "_.Pasteclip" "0,0")
(setvar "tilemode" CRT);
);

 

Appriciate any help on this. Let me know if I'm not explaining well enough.

Posted
CHSAPACE command?

 

TYPO alert, I suspect that was meant to be CHSPACE, a great command.

It won't do everything you are hoping for, because it will delete the one which is moved.

You could of course create a COPY at the same coordinates, then move one of them.

Posted

I have tried CHSPACE command. It works but considering my requirements (creating a copy instead of moving it, extracting from Attribute block, Viewport scale adjustment) it requires more than just one standard command. May be a routine which takes care of these.

 

Now, the question is, do you guys think its doable or I'm way off on these?

Posted

Can someone please help me on this? Atleast give me a clue whether possible or not.

Posted

I can't help you with LISP, but copying the objects and the using the select command and the previous option, selects one set of items that you can then use the chspace command on, so you then have the items in model space and paperspace

Posted

steven-g

 

Thats right, thats the first part and I see it takes care of the viewport scaling adjustment so 2 of my requirements are met. Now extracting only circles from the attribute blocks requires ncopy command. Now when I use ncopy it copies and asks me for basepoint/displacement. And it only allows one object per selection. This seems too long and thats why I thought someone might be able to create a quick routine that would take care of all this.

 

I like your suggestion though.

 

And here is how I thought should work

1) Jumps into Model space from viewport (I might have to lock display)

2) Allows me to extract entities from Attribute blocks

3) Once I'm done selecting, Jumps back to Paperspace

4) Copies them to Paperspace at the exact same location (just what CHSPACE does it).

5) Command closes.

Posted

OK again thinking out loud, I use LT so no LISP, and no way to select individual items within a block, but how I would do it would be copy everything, transfer copy to paperspace, then explode everything and delete all non circles. How you do that in LISP ??? I wouldn't know

Posted

Copying everything then exploding would require erasing work and depending on the block content, it might take more work than simply ncopy.

 

And as far as the lisp goes, I dont know much either (know just a bit to be able to make simple ones and modify for my use) and thats why I'm asking for help from LISP gurus here...I know there are many gurus who might want to give a shot at this.

Posted

I'm happy to assist, but currently don't have much time to look at this - maybe over the weekend if I get a minute.

Posted
I'm happy to assist, but currently don't have much time to look at this - maybe over the weekend if I get a minute.

Would you actually need the whole minute. :D

Posted

I found some time to look at this and have written the following as a quick draft, however the program is currently limited to use in viewports for which viewtwist is zero:

[color=GREEN];; Modelspace to Paperspace  -  Lee Mac[/color]

([color=BLUE]defun[/color] c:ms2ps ( [color=BLUE]/[/color] doc idx lst mat org sel )
   ([color=BLUE]cond[/color]
       (   ([color=BLUE]=[/color] 1 ([color=BLUE]getvar[/color] 'tilemode))
           ([color=BLUE]prompt[/color] [color=MAROON]"\nCommand only available in Paperspace."[/color])
       )
       (   ([color=BLUE]=[/color] 1 ([color=BLUE]getvar[/color] 'cvport))
           ([color=BLUE]prompt[/color] [color=MAROON]"\nPlease activate a viewport."[/color])
       )
       (   ([color=BLUE]setq[/color] sel ([color=BLUE]ssget[/color] '((410 . [color=MAROON]"Model"[/color]))))
           ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] idx ([color=BLUE]sslength[/color] sel))
               ([color=BLUE]setq[/color] lst ([color=BLUE]cons[/color] ([color=BLUE]vlax-ename->vla-object[/color] ([color=BLUE]ssname[/color] sel ([color=BLUE]setq[/color] idx ([color=BLUE]1-[/color] idx)))) lst))
           )
           ([color=BLUE]setq[/color] mat
               ([color=BLUE]vlax-tmatrix[/color]
                   ([color=BLUE]append[/color]
                       ([color=BLUE]mapcar[/color]
                          '([color=BLUE]lambda[/color] ( a b )
                               ([color=BLUE]append[/color] ([color=BLUE]mapcar[/color] '[color=BLUE]-[/color] ([color=BLUE]trans[/color] ([color=BLUE]trans[/color] a 0 2) 2 3) org) ([color=BLUE]list[/color] b))
                           )
                          '(
                               (1.0 0.0 0.0)
                               (0.0 1.0 0.0)
                               (0.0 0.0 1.0)
                           )
                           ([color=BLUE]setq[/color] org ([color=BLUE]trans[/color] ([color=BLUE]trans[/color] '(0.0 0.0 0.0) 0 2) 2 3))
                       )
                      '((0.0 0.0 0.0 1.0))
                   )
               )
           )
           ([color=BLUE]foreach[/color] obj
               ([color=BLUE]vlax-invoke[/color] ([color=BLUE]setq[/color] doc ([color=BLUE]vla-get-activedocument[/color] ([color=BLUE]vlax-get-acad-object[/color]))) 'copyobjects lst
                   ([color=BLUE]vla-get-block[/color]
                       ([color=BLUE]vla-item[/color]
                           ([color=BLUE]vla-get-layouts[/color] doc)
                           ([color=BLUE]getvar[/color] 'ctab)
                       )
                   )
               )
               ([color=BLUE]vla-transformby[/color] obj mat)
           )
       )
   )
   ([color=BLUE]princ[/color])
)
([color=BLUE]vl-load-com[/color]) ([color=BLUE]princ[/color])

Posted

This is what we use in the office before.

the commands are :

 

C2P = copy to paperspace & M2P = move to paperspace

C2M = copy to modelspace & M2M = move to modelspace

 

However it has this "Buy Me" thing.

 

Put all in one folder and that folder should be listed in the autocad's support folder

SP2SP.LSP

sp2sp.dcl

SP2SP.zip

Posted
I found some time to look at this and have written the following as a quick draft, however the program is currently limited to use in viewports for which viewtwist is zero:

 

Thanks Lee for sparing time for this. Here are my observations:

 

1) Is it possible to let user activate the viewport instead of terminating command?

2) Its not extracting the selected entity. Currently its copying the whole block (this is a must have thing)

3) Can viewport display be locked temporary otherwise if user zooms in while in Model space mode, it may mess up the drawing. (safety feature)

4) When selection is done, can it come back to Paper space automatically and then close the command.

 

Not sure which of these can't be done, but still I want to mention it so that you can decide better.

 

Nod684: I can't use the codes that you posted since it has some copyright stuff in there. Thanks for your help though.

  • 2 weeks later...
Posted

Hi Lee,

 

I see you have added MS2PS on your website. Is there a possibility to add some of my wishlist/requirements listed in post #16.

Posted

Here's how to lock/unlock a viewport (vpObj)

(vla-put-DisplayLocked vpObj [:vlax-true / :vlax-false] )

where you'd :vlax-true to lock it and :vlax-false to unlock it.

 

And then to switch between paper space and model space in a lisp routine, you'd use TILEMODE, in the following manner:

credits to Zorg for the following:

(defun c:mm( / )
(command "_tilemode" "1")
)
(defun c:pm( / )
(command "_tilemode" "0")
)

 

 

Not sure what you mean by "extracting" the entities....

 

and then instead of terminating the command, to allow the user to select the viewport ....you could use this function, written by Lee Mac

(defun c:vpon ( / d s )
   (vl-load-com)
   (if (setq s (ssget "_+.:S:E:L" '((0 . "VIEWPORT"))))
       (progn
           (setq d (vla-get-activedocument (vlax-get-acad-object)))
           (vla-put-mspace d :vlax-true)
           (vla-put-activeviewport d (vlax-ename->vla-object (ssname s 0)))
       )
   )
   (princ)
)

(defun c:vpoff ( )
   (vla-put-mspace (vla-get-activedocument (vlax-get-acad-object)) :vlax-false)
   (princ)
)

 

You could incorporate these pieces of code into Lee's full routine to create a customized version for your own needs. I wouldn't expect Lee to modify his complete program for your needs but if these are more upgrades than personal modifications, then he may!

I know this requires some effort from you as well but I'm hoping I gave enough of a head start for you to be successful.

HTH

Posted

bhull1985,

 

I will give a shot at this. Lets see what I can do with this though with my limited LISP knowledge. Thanks for your helpful tips.

Posted

You're very welcome.

At the minimum you could find the parts to be replaced, and then come ask how to do it here :P

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...