| Author |
Message |
RaghuMN
Guest
|
Posted:
Wed Mar 23, 2005 4:36 pm Post subject:
Processing between 2 drawings? |
|
|
Hi all,
I have a (only one) drawing open.
My intention is to:
1. 'copyclip' some features from this drawing.
2. Open another drawing
3. Paste the copied features into the newly opened drawing.
4. Save and close this new drawing.
5. Get back to the old drawing and continue to repeat the cycle.
Tried as follows till step 3:
(defun c:cp()
(setq sset (ssget)) ;from current drawing
(command "copyclip" sset "")
(command "._VBAStmt" (strcat "AcadApplication.Documents.Open \"" "c:/junk.dwg" "\"")
(command "pasteorig") ;does not work in new drawing.
)
As soon as the new drawing is opened, it becomes the current. But, the line (command "pasteorig") does not get executed here since the program belongs to old drawing.
Any tips on what to do so that I can continue to perform the steps 3, 4, 5?
Thanks for any help.
MNRaghu
|
|
| Back to top |
|
 |
Adesu
Guest
|
Posted:
Thu Mar 24, 2005 10:01 am Post subject:
Re: Processing between 2 drawings? |
|
|
HI RaghuMN,I have a script as like your own,but this script still few
problem,maybe you wish try it,here this script,I've tested and got problem
in "SDI"
(vl-load-com)
(setq osdi (getvar "SDI"))
(setvar "SDI" 1)
(setq oli (getvar "LISPINIT"))
(setvar "LISPINIT" 0)
(setq file1 "C:/Auto CAD 2000/Drawing1.DWG")
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) file1))
(setq loc (list 0 0))
(setq hei 1)
(setq str "Adesu")
(command "_text" loc hei "" str "")
(prompt "\nSELECT A TEXT")
(setq ss (ssget "x" '((0 . "TEXT"))))
(command "_copyclip" ss "")
(setq file2 "C:/Auto CAD 2000/Drawing2.DWG")
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object)) file2))
(setq p1 (list 10 10))
(command "_pasteclip" p1 "")
(setvar "SDI" osdi)
(setvar "LISPINIT" oli)
RaghuMN <nospam@address.withheld> wrote in message
news:7030187.1111577820877.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | Hi all,
I have a (only one) drawing open.
My intention is to:
1. 'copyclip' some features from this drawing.
2. Open another drawing
3. Paste the copied features into the newly opened drawing.
4. Save and close this new drawing.
5. Get back to the old drawing and continue to repeat the cycle.
Tried as follows till step 3:
(defun c:cp()
(setq sset (ssget)) ;from current drawing
(command "copyclip" sset "")
(command "._VBAStmt" (strcat "AcadApplication.Documents.Open \""
"c:/junk.dwg" "\"")
(command "pasteorig") ;does not work in new drawing.
)
As soon as the new drawing is opened, it becomes the current. But, the
line (command "pasteorig") does not get executed here since the program |
belongs to old drawing.
| Quote: |
Any tips on what to do so that I can continue to perform the steps 3, 4,
5?
Thanks for any help.
MNRaghu |
|
|
| Back to top |
|
 |
Joe Burke
Guest
|
Posted:
Thu Mar 24, 2005 3:52 pm Post subject:
Re: Processing between 2 drawings? |
|
|
Hi RaghuMN,
Have you considered using Active X and the Documents collection or ObjectDBX?
Code outline using Documents collection. Let's assume you have three files open and
you want to copy a selection set in model space from the active drawing to the other
two. As you said, you want the selection set at the same coordinates, like pasteorig,
in the other two.
1 - Get the active document: (setq *doc* (vla-get-ActiveDocument
(vlax-get-acad-object))).
2 - Get the Documents collection. Assign to symbol *documents*.
3 - Make a list of vla-objects from the selection set. Assign to symbol CopyLst.
4 - Step through the Documents collection (vlax-for item *documents*... but skip the
active document.
5 - Get the model space collection for each document during step 4. Assign to symbol
*mspace*.
6 - Copy the list of vla-objects during step 4 like this.
(vlax-invoke *doc* 'CopyObjects CopyLst *mspace*)
7 - Save or not during step 4.
I think you have to regen the other files before you'll see the copied objects. Not
sure about that.
The same operation can be done using ObjectDBX. What would differ is how you
access/specify the copy to files. For instance, you could copy the selection set to
all files in a folder. Or simply select one file at a time using getfiled.
I appreciate this is beyond the scope of your question. But it should solve the
problem. And it might give you some ideas on how to approach similar tasks.
Joe Burke
| Quote: | Hi all,
I have a (only one) drawing open.
My intention is to:
1. 'copyclip' some features from this drawing.
2. Open another drawing
3. Paste the copied features into the newly opened drawing.
4. Save and close this new drawing.
5. Get back to the old drawing and continue to repeat the cycle.
Tried as follows till step 3:
(defun c:cp()
(setq sset (ssget)) ;from current drawing
(command "copyclip" sset "")
(command "._VBAStmt" (strcat "AcadApplication.Documents.Open \"" "c:/junk.dwg"
"\"")
(command "pasteorig") ;does not work in new drawing.
)
As soon as the new drawing is opened, it becomes the current. But, the line
(command "pasteorig") does not get executed here since the program belongs to old
drawing.
Any tips on what to do so that I can continue to perform the steps 3, 4, 5?
Thanks for any help.
MNRaghu |
|
|
| Back to top |
|
 |
Nirmal
Guest
|
Posted:
Thu Mar 24, 2005 4:19 pm Post subject:
Re: Processing between 2 drawings? |
|
|
By my experience, you can do it using VBA only.
Nirmal |
|
| Back to top |
|
 |
Joe Burke
Guest
|
Posted:
Thu Mar 24, 2005 5:16 pm Post subject:
Re: Processing between 2 drawings? |
|
|
Nirmal,
IMO, not T. Though I'm not familiar with VBA.
Joe Burke
| Quote: | By my experience, you can do it using VBA only.
Nirmal |
|
|
| Back to top |
|
 |
RaghuMN
Guest
|
Posted:
Thu Mar 24, 2005 5:48 pm Post subject:
Re: Processing between 2 drawings? |
|
|
Joe Burke,
Thanks for the detailed information.
I'll give a try on the ActiveX method that you have suggested. This method seems to work ideally, though I am not able to put my hands on it now.
( I am too far from Object DBX, hence, I can't try that now.)
I am leaving now for a vacation and be back by mid next week.
Adesu,
Thanks for the code. I'll surely give this a try and get back.
Thanks,
MNRaghu |
|
| Back to top |
|
 |
Joe Burke
Guest
|
Posted:
Thu Mar 24, 2005 6:50 pm Post subject:
Re: Processing between 2 drawings? |
|
|
MNRaghu,
You're welcome.
Post any questions you might have here, when you return from vacation.
BTW, the ObjectDBX thing may look like black magic. But in fact, it isn't.
Joe Burke
| Quote: | Joe Burke,
Thanks for the detailed information.
I'll give a try on the ActiveX method that you have suggested. This method seems to
work ideally, though I am not able to put my hands on it now.
( I am too far from Object DBX, hence, I can't try that now.)
I am leaving now for a vacation and be back by mid next week.
Adesu,
Thanks for the code. I'll surely give this a try and get back.
Thanks,
MNRaghu |
|
|
| Back to top |
|
 |
Tony Tanzillo
Guest
|
Posted:
Thu Mar 24, 2005 7:18 pm Post subject:
Re: Processing between 2 drawings? |
|
|
"Joe Burke" <joburke@hawaii.rr.com> wrote
| Quote: | BTW, the ObjectDBX thing may look like black magic. But in fact, it isn't.
|
No, as long as you don't have to do things like modify
non-default justified text or attributes. For that, you'll
need a C++ based solution, which can be viewed by
some as not that much unlike black magic :-)
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com |
|
| Back to top |
|
 |
Joe Burke
Guest
|
Posted:
Thu Mar 24, 2005 9:07 pm Post subject:
Re: Processing between 2 drawings? |
|
|
Tony,
Thanks for the heads-up as usual. I didn't know that.
BTW, regardless of my ignorance, it's nice to see a light touch from your end.
Joe Burke
| Quote: |
BTW, the ObjectDBX thing may look like black magic. But in fact, it isn't.
No, as long as you don't have to do things like modify
non-default justified text or attributes. For that, you'll
need a C++ based solution, which can be viewed by
some as not that much unlike black magic :-)
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
http://www.acadxtabs.com
|
|
|
| Back to top |
|
 |
RaghuMN
Guest
|
Posted:
Fri Apr 01, 2005 10:02 am Post subject:
Re: Processing between 2 drawings? |
|
|
Hi Joe Burke,
I again studied your suggestions.
You have assumed that I already have 3 drawings open and built the rest of the processing logic is based on it.
My case is slightly different, wherein I have only one drawing open.
I search for features based on certain parameters in this drawing.
If features are found, I need to open another drawing whose name is logically related to these selected features.
These features should then be pasted into the newly opened drawing, saved and closed to return back to the old drawing.
The cycle should again repeat (lisp should continue executing) with searching for features based on certain parameters in the old drawing.
The problem for me is that the lisp stops executing once the new drawing is opened which automatically gets activated.
I assume that the logic that you have suggested has control over the currently open drawings, but not with the then newly opened drawing.
Have I misunderstood your logic or is there any other way to get what I need? Please comment.
----------
Hi Adesu,
I tried your function, but does not get executed since the functions "VLA-ACTIVATE" and "VLA-OPEN" does not exist (I use 2002). Can you extend your help further on this subject?
Thank you both,
MNRaghu |
|
| Back to top |
|
 |
Joe Burke
Guest
|
Posted:
Fri Apr 01, 2005 9:21 pm Post subject:
Re: Processing between 2 drawings? |
|
|
Hi RaghuMN,
My first post in this thread suggested two possible methods. Use the Documents
collection (all open files), or ObjectDBX.
In some cases it's easier to use the Documents collection. That way you control the
set of files to be modified or examined based on the fact they are open.
The other way uses ObjectDBX to select files to be examined or modified. That's a
one-at-a-time process in the sense there can only be one "active" ODBX document.
That's not meat to imply you can't process a list of files using ODBX. Only that you
must deal with each one separately. IOW, open, modify, save, one-at-a-time.
It sounds like you want to use the ObjectDBX method. If so, you will not have a
problem with, "...lisp stops executing..." because ODBX does not open the file in
question in the graphics editor. Rather it opens the file in memory. That may be a
poor explanation of what's actually going on. I defer to others to explain it more
accurately.
I'll post some sample code to demonstrate how it might be done using ODBX if that
would be useful. Let me know.
Regards
Joe Burke
| Quote: | Hi Joe Burke,
I again studied your suggestions.
You have assumed that I already have 3 drawings open and built the rest of the
processing logic is based on it.
My case is slightly different, wherein I have only one drawing open.
I search for features based on certain parameters in this drawing.
If features are found, I need to open another drawing whose name is logically
related to these selected features.
These features should then be pasted into the newly opened drawing, saved and
closed to return back to the old drawing.
The cycle should again repeat (lisp should continue executing) with searching for
features based on certain parameters in the old drawing.
The problem for me is that the lisp stops executing once the new drawing is opened
which automatically gets activated.
I assume that the logic that you have suggested has control over the currently open
drawings, but not with the then newly opened drawing.
Have I misunderstood your logic or is there any other way to get what I need?
Please comment.
----------
Hi Adesu,
I tried your function, but does not get executed since the functions "VLA-ACTIVATE"
and "VLA-OPEN" does not exist (I use 2002). Can you extend your help further on
this subject?
Thank you both,
MNRaghu |
|
|
| Back to top |
|
 |
RaghuMN
Guest
|
Posted:
Sat Apr 02, 2005 8:59 am Post subject:
Re: Processing between 2 drawings? |
|
|
Joe Burke,
Thanks for the information.
As you have explained, the ObjectDBX method seems to fulfill my requirement.
But, since I do not have any exposure to ObjectDBX method as of now, I would not seek any help on this issue, though I am interested at some point of time in future.
W.r.t the vlisp / activex method, could you please let me know of any other possibilities to perform this task?
(I do have in my mind of using the script and performing the paste task in another session, but keeping it as the last resort.)
Thanks for the help offered.
MNRaghu |
|
| Back to top |
|
 |
Joe Burke
Guest
|
Posted:
Sat Apr 02, 2005 4:15 pm Post subject:
Re: Processing between 2 drawings? |
|
|
MNRaghu,
You're welcome.
Regarding other possibilities, nothing comes to mind.
Joe Burke
| Quote: | Joe Burke,
Thanks for the information.
As you have explained, the ObjectDBX method seems to fulfill my requirement.
But, since I do not have any exposure to ObjectDBX method as of now, I would not
seek any help on this issue, though I am interested at some point of time in
future.
W.r.t the vlisp / activex method, could you please let me know of any other
possibilities to perform this task?
(I do have in my mind of using the script and performing the paste task in another
session, but keeping it as the last resort.)
Thanks for the help offered.
MNRaghu |
|
|
| Back to top |
|
 |
Alan Henderson @ A'cad So
Guest
|
Posted:
Sat Apr 02, 2005 6:34 pm Post subject:
Re: Processing between 2 drawings? |
|
|
If you do not use acaddoc.lsp files, you could create a temporary
acaddoc.lsp file that runs when the drawings are created, then delete the
file when finished.
If you use acaddoc.lsp files, rename the file, create a new temporary
acaddoc.lsp file, create drawings, then delete the new file and rename the
old file.
"RaghuMN" <nospam@address.withheld> wrote in message
news:7030187.1111577820877.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | Hi all,
I have a (only one) drawing open.
My intention is to:
1. 'copyclip' some features from this drawing.
2. Open another drawing
3. Paste the copied features into the newly opened drawing.
4. Save and close this new drawing.
5. Get back to the old drawing and continue to repeat the cycle.
Tried as follows till step 3:
(defun c:cp()
(setq sset (ssget)) ;from current drawing
(command "copyclip" sset "")
(command "._VBAStmt" (strcat "AcadApplication.Documents.Open \""
"c:/junk.dwg" "\"")
(command "pasteorig") ;does not work in new drawing.
)
As soon as the new drawing is opened, it becomes the current. But, the
line (command "pasteorig") does not get executed here since the program |
belongs to old drawing.
| Quote: |
Any tips on what to do so that I can continue to perform the steps 3, 4,
5?
Thanks for any help.
MNRaghu |
|
|
| Back to top |
|
 |
Tony Tanzillo
Guest
|
Posted:
Sat Apr 02, 2005 8:43 pm Post subject:
Re: Processing between 2 drawings? |
|
|
"Joe Burke" <joburke@hawaii.rr.com> wrote
| Quote: | The other way uses ObjectDBX to select files to be examined or modified. That's a one-at-a-time process in the sense
there can only be one "active" ODBX document. That's not meat to imply you can't process a list of files using ODBX.
Only that you must deal with each one separately. IOW, open, modify, save, one-at-a-time.
|
Joe - Can you expound on this? I'm not sure what you mean
by '"active" ODBX document'. ObjectDBX does not support the concept
of an 'Active document' in an exclusive sense, and an ObjectDBX document
is never active in the same way that documents in the drawing editor are.
AFAIK, there is no limitation on the number of ObjectDBX documents
that can be opened or accessed concurrently, contrary to what you
write above ('one-at-a-time') seems to suggest.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com |
|
| Back to top |
|
 |
|
|
|
|