Processing between 2 drawings?
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Processing between 2 drawings?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
Jeff Mishler
Guest





Posted: Sun Apr 03, 2005 3:11 am    Post subject: Re: Processing between 2 drawings? Reply with quote

Tony, I think that what Joe is referring to is that, unlike the
AcadApplication that has a Documents Collection, ObjectDBX does not, thereby
making it a 'one at a time' Application. Of course, that does NOT imply that
you can't have more than one instance of an ObjectDBX Application which
would allow you to work with more than one at a time.

Joe, here's a quick sample that shows that you can have more than one open
at a time:
Code:

(defun odbx-test ( / *acad* num dwg1 dwg2 dwg3)
  (setq *acad* (vlax-get-acad-object)
            num 1.0)
  (mapcar '(lambda (x)
      (set (read x) (vla-getinterfaceobject *acad*
"ObjectDBX.AxDbDocument"))
      (vla-open (eval (read x)) (strcat "c:\\testing" (itoa (fix num))
".dwg"))
      (vlax-invoke (vla-get-modelspace (eval (read x))) 'addcircle (list num
num 0.0) num)
      (setq num (+ num 1.0))
      (vla-saveas (eval (read x)) (vla-get-name (eval (read x))))
      )
   (list "dwg1" "dwg2" "dwg3")
   )
  (foreach x (list dwg1 dwg2 dwg3)
    (princ (strcat "\nObjectDBX Drawing named: " (vla-get-name (eval x)) "
is now open..."))
    )
  (mapcar '(lambda (x)
      (vlax-release-object (eval (read x))))
   (list "dwg1" "dwg2" "dwg3")
   )
  (princ)
  )


--
Jeff
check out www.cadvault.com
"Tony Tanzillo" <tony.tanzillo@U_KNOW_WHERE.com> wrote in message
news:424ebdce$1_3@newsprd01...
Quote:
"Joe Burke" <joburke@hawaii.rr.com> wrote

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
Joe Burke
Guest





Posted: Sun Apr 03, 2005 2:35 pm    Post subject: Re: Processing between 2 drawings? Reply with quote

Tony,

Thanks for the heads-up. I was not aware multiple ObjectDBX documents may be accessed
concurrently. A wrong assumption on my part.

I was trying to make a point, as Jeff suggested, that the Documents collection might
be a convenient mechanism to use given the question at hand. Particularly if the OP
is not familiar with ODBX. Which turned out to be the case.

My other thought related to "one-at-a-time" was the idea getfiled only allows single
document selection. So each document might as well be dealt with separately codewise:
Open, CopyObjects, SaveAs, Close. Of course what I forgot was DOSLib dos_getfilem.
Which is what I would use with the approach Jeff posted.

I should know better than to make assumptions I haven't tested. Worse, post as fact
here. On the other hand, at least I learned something valuable.

Thank you,
Joe Burke

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
Joe Burke
Guest





Posted: Sun Apr 03, 2005 4:37 pm    Post subject: Re: Processing between 2 drawings? Reply with quote

Hi Jeff,

Thanks for the code example. I ran it (modified for 2004) and note the incremented
circle added to each file.

I wonder if you've found a practical application for the idea of multiple concurrent
ODBX files? See my reply to Tony regarding dos_getfilem, which returns a list of file
names, with qualified path first.

Given that my first thought, in terms of this thread, would be something like
(foreach x (cdr lst) (setq fullpath (strcat (car lst) x)) Open <do stuff> SaveAs...
So each file would be processed in turn, rather than having all selected files open
at the same time.

I appreciate your example may only be intended to demonstrate multiple concurrent
ODBX files. I'm just asking the next obvious question. Are there applications for the
idea which haven't dawned on me yet?

Regards
Joe Burke

"Jeff Mishler" <jeff_m@cadvault.com> wrote in message news:424f189e_1@newsprd01...
Quote:
Tony, I think that what Joe is referring to is that, unlike the AcadApplication
that has a Documents Collection, ObjectDBX does not, thereby making it a 'one at a
time' Application. Of course, that does NOT imply that you can't have more than one
instance of an ObjectDBX Application which would allow you to work with more than
one at a time.

Joe, here's a quick sample that shows that you can have more than one open at a
time:
Code:

(defun odbx-test ( / *acad* num dwg1 dwg2 dwg3)
(setq *acad* (vlax-get-acad-object)
num 1.0)
(mapcar '(lambda (x)
(set (read x) (vla-getinterfaceobject *acad* "ObjectDBX.AxDbDocument"))
(vla-open (eval (read x)) (strcat "c:\\testing" (itoa (fix num)) ".dwg"))
(vlax-invoke (vla-get-modelspace (eval (read x))) 'addcircle (list num num
0.0) num)
(setq num (+ num 1.0))
(vla-saveas (eval (read x)) (vla-get-name (eval (read x))))
)
(list "dwg1" "dwg2" "dwg3")
)
(foreach x (list dwg1 dwg2 dwg3)
(princ (strcat "\nObjectDBX Drawing named: " (vla-get-name (eval x)) " is now
open..."))
)
(mapcar '(lambda (x)
(vlax-release-object (eval (read x))))
(list "dwg1" "dwg2" "dwg3")
)
(princ)
)


--
Jeff
check out www.cadvault.com
"Tony Tanzillo" <tony.tanzillo@U_KNOW_WHERE.com> wrote in message
news:424ebdce$1_3@newsprd01...
"Joe Burke" <joburke@hawaii.rr.com> wrote

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
Jeff Mishler
Guest





Posted: Sun Apr 03, 2005 10:57 pm    Post subject: Re: Processing between 2 drawings? Reply with quote

"Joe Burke" <joburke@hawaii.rr.com> wrote in message
news:424fd5ae$1_2@newsprd01...
Quote:
Hi Jeff,

Thanks for the code example. I ran it (modified for 2004) and note the
incremented circle added to each file.
You're welcome.

I wonder if you've found a practical application for the idea of multiple
concurrent ODBX files? See my reply to Tony regarding dos_getfilem, which
returns a list of file names, with qualified path first.

Well, now ya got me. No, I have never had a need for multiple files....yet.

And, in fact, I had never even thought about it until I read Tony's response
to you. So I went exploring..... ;-) What can I say, it was a rainy Saturday
and I was bored.

Quote:
Given that my first thought, in terms of this thread, would be something
like (foreach x (cdr lst) (setq fullpath (strcat (car lst) x)) Open <do
stuff> SaveAs... So each file would be processed in turn, rather than
having all selected files open at the same time.

I would approach this using the Windows FileSystemObject in place of DOSLib,

only because you don't need to make sure you have the correct DOSLib for
each version....

Quote:
I appreciate your example may only be intended to demonstrate multiple
concurrent ODBX files. I'm just asking the next obvious question. Are
there applications for the idea which haven't dawned on me yet?
I'm sure there are, and now that you know it's possible they may be found

that much sooner.

Quote:

Regards
Joe Burke

Jeff
Back to top
Tony Tanzillo
Guest





Posted: Mon Apr 04, 2005 1:03 am    Post subject: Re: Processing between 2 drawings? Reply with quote

"Jeff Mishler" <jeff_m@cadvault.com> wrote


Quote:
Tony, I think that what Joe is referring to is that, unlike the AcadApplication that has a Documents Collection,
ObjectDBX does not, thereby making it a 'one at a time' Application.

Sorry, I still don't follow that logic.

I don't see how the lack of a documents collection makes ObjectDBX
a 'one-at-a-time' application. It only means that you don't iterate
over a collection exposed by AutoCAD (of course, you can quite easily
maintain your own Collection of AxDbDocuments).

An AxDbDocument represents an AutoCAD drawing on disk.

I read Joe's comments to infer that you can only manipulate
or access one of those at a time.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
Back to top
Tony Tanzillo
Guest





Posted: Mon Apr 04, 2005 3:58 am    Post subject: Re: Processing between 2 drawings? Reply with quote

"Joe Burke" <joburke@hawaii.rr.com> wrote

Quote:
I wonder if you've found a practical application for the idea of multiple concurrent ODBX files? See my reply to Tony
regarding dos_getfilem, which returns a list of file names, with qualified path first.


One could just as easily ask what practical applications are
there in being able to concurrently access multiple files of any
type (ASCII text files, word documents, spreadsheets, etc.).

If you'd like a concrete example, I've done applications that
propagate data from a single 'source' drawing, to multiple target
drawings. The source drawing stays open in an AxDbDocument,
and each target drawing is sequentially opened; updated by
copying objects into it from the source drawing; and then saved.

Another example that is somewhat the inverse of that, is an
application that works like AutoCAD MAP, where you can execute
a 'query' of sorts, against many .DWG files on disk, and have the
resulting entities that match the query copied into a single
document (which can be either an open drawing in the editor,
or DWG file on disk).


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
Back to top
Joe Burke
Guest





Posted: Mon Apr 04, 2005 5:39 am    Post subject: Re: Processing between 2 drawings? Reply with quote

Tony,

I guess my question to Jeff wasn't clear. I'm not questioning the idea of using
ObjectDBX to operate on multiple files. Rather the idea you might have all of them
open at the same time.

I think your second paragraph below suggests each document is opened, updated, saved
and released in sequence.

Joe Burke

Quote:
I wonder if you've found a practical application for the idea of multiple
concurrent ODBX files? See my reply to Tony regarding dos_getfilem, which returns
a list of file names, with qualified path first.


One could just as easily ask what practical applications are
there in being able to concurrently access multiple files of any
type (ASCII text files, word documents, spreadsheets, etc.).

If you'd like a concrete example, I've done applications that
propagate data from a single 'source' drawing, to multiple target
drawings. The source drawing stays open in an AxDbDocument,
and each target drawing is sequentially opened; updated by
copying objects into it from the source drawing; and then saved.

Another example that is somewhat the inverse of that, is an
application that works like AutoCAD MAP, where you can execute
a 'query' of sorts, against many .DWG files on disk, and have the
resulting entities that match the query copied into a single
document (which can be either an open drawing in the editor,
or DWG file on disk).


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

Back to top
RaghuMN
Guest





Posted: Tue Apr 05, 2005 9:03 am    Post subject: Re: Processing between 2 drawings? Reply with quote

Thanks Alan,

This is a good idea. I'll try and get back.
Ideally, this SHOULD work.

Thanks,

MNRaghu
Back to top
Tony Tanzillo
Guest





Posted: Tue Apr 05, 2005 9:47 pm    Post subject: Re: Processing between 2 drawings? Reply with quote

"Joe Burke" <joburke@hawaii.rr.com> wrote

Quote:
I guess my question to Jeff wasn't clear. I'm not questioning the idea of using ObjectDBX to operate on multiple
files. Rather the idea you might have all of them open at the same time.

Joe - I read 'multiple concurrent ODBX files' as meaning more
than one, but not necessarily 'all of them'.

For processing multiple drawing files, I can't think of any reason
why they should all be open concurrently, and that's not a wise
thing to do.

Quote:
I think your second paragraph below suggests each document is opened, updated, saved and released in sequence.

Yes, while another AxDbDocument remained open, hence the
example had two AxDbDocuments open concurrently.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
Back to top
LUCAS
Guest





Posted: Wed Apr 06, 2005 9:03 am    Post subject: Re: Processing between 2 drawings? Reply with quote

;;BY LUCAS
;;Make sure the other dwg not opened
(defun C:COPY_2_OTHER_DWG (/ DOC LST N NEWDWG SS NAME)
(vl-load-com)
(if (and (setq SS (ssget (list (cons 410 (getvar "ctab"))
(cons 0 (strcat "~" "VIEWPORT"))
)
)
)
(setq NAME (getfiled "Select Dwg" (getvar "ACADPREFIX") "dwg" 8))
(setq NAME (findfile NAME))
)
(progn
(setq N -1
DOC (vla-get-activedocument (vlax-get-acad-object))
NEWDWG (vla-open (vla-get-documents (vlax-get-acad-object))
NAME
)
)
(repeat (sslength SS)
(setq LST
(cons (vlax-ename->vla-object (ssname SS (setq N (1+ N))))
LST
)
)
)
(vla-copyobjects
DOC
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbobject
(cons 0 (1- (length LST)))
)
LST
)
(if (equal (getvar "ctab") "Model")
(vla-get-modelspace NEWDWG)
(vla-get-paperspace NEWDWG)
)
)
(vla-saveas NEWDWG NAME acnative)
(vla-close NEWDWG)
(vlax-release-object DOC)
(vlax-release-object NEWDWG)
)
)
(princ)
)
--

http://www.mjtd.com/bbs/
Back to top
Joe Burke
Guest





Posted: Wed Apr 06, 2005 3:44 pm    Post subject: Re: Processing between 2 drawings? Reply with quote

Tony,

Thanks for the clarification. Also for your input on this topic. It is appreciated.

Joe Burke


Quote:
"Joe Burke" <joburke@hawaii.rr.com> wrote

I guess my question to Jeff wasn't clear. I'm not questioning the idea of using
ObjectDBX to operate on multiple files. Rather the idea you might have all of them
open at the same time.

Joe - I read 'multiple concurrent ODBX files' as meaning more
than one, but not necessarily 'all of them'.

For processing multiple drawing files, I can't think of any reason
why they should all be open concurrently, and that's not a wise
thing to do.

I think your second paragraph below suggests each document is opened, updated,
saved and released in sequence.

Yes, while another AxDbDocument remained open, hence the
example had two AxDbDocuments open concurrently.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

Back to top
RaghuMN
Guest





Posted: Thu Apr 07, 2005 9:09 am    Post subject: Re: Processing between 2 drawings? Reply with quote

LUCAS,

Very useful, nice and appreciated.
Thanks for the help.

MNRaghu
Back to top
Joe Burke
Guest





Posted: Thu Apr 07, 2005 4:40 pm    Post subject: Re: Processing between 2 drawings? Reply with quote

MNRaghu,

I have tested code based on the methods I suggested previously. I'll post if you care
to take a look.

The copy to (target) documents may be open or closed.

It has an option I often find useful. Copy the objects as a group to target
documents. That allows easy selection of the copied objects when they were placed on
existing crowded layers.

Joe Burke
Back to top
RaghuMN
Guest





Posted: Fri Apr 08, 2005 4:19 pm    Post subject: Re: Processing between 2 drawings? Reply with quote

Joe Burke,

Many Thanks for the offer.

I am curious to know the method that you have adopted and I request you to share the code that you have written.

Sorry that I could not work much (due to changed job priorities) on your guidelines that you gave me earlier, though they were meaningful.

Thanks,

MNRaghu
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB