Author Topic: Object DBX - open drawing, draw stuff & get selection sets.  (Read 2757 times)

0 Members and 1 Guest are viewing this topic.

TimAshby

  • Guest
I'm looking to process a bunch of drawings with objectDBX.

As a start, I want to:

open a drawing
draw a rectangle from 0,0 to 5,5
get a crossing selection set from 0,0 to 10,10 & store to a variable.

Pinching & tweaking from previous google searches (thanks to Lee Mac & T. Willey) I have the following:

Annotations are mine, any corrections gratefully received. I'm unsure 'pointer' is the correct terminology, but hey.

Code: [Select]
;$dwg = valid filename
;returns = nil or AcadDocument

(defun _GetDocObj ( $dwg / app dbx doc)

    (cond
      ;check that the file exists & is the one we expect
      ((not (equal (vl-string-translate "/" "\\" $dwg)
   (vl-string-translate "/" "\\" (findfile $dwg))
   ))
       (prompt "\nFile in multiple places?")
       nil
       )
      ;check that the $dwg is not open, ie a member of the open documents in this acad object
      ((member $dwg (vlax-for doc (vla-get-Documents (setq app (vlax-get-acad-object)))))
       (prompt "\nFile open")
       nil
       )
      ;get the dbx pointer for current acad doc
      ((not (setq dbx
       (vl-catch-all-apply
'vla-GetInterfaceObject
(list
   app
   (if (< (atoi (setq #oVer (substr (getvar "acadver") 1 2))) 16)
     "ObjectDBX.AxDbDocument"
     (strcat "ObjectDBX.AxDbDocument." #oVer))
   ))))
       (prompt "\nObjectDBX failed")
       nil
       )
      ;if the pointer is null or is an error
      ((or (null dbx)(vl-catch-all-error-p dbx))
       (prompt "\nObjectDBX failed")
       nil
       )
      ;try to open the dbx document
      ((vl-catch-all-error-p (setq doc (vl-catch-all-apply 'vla-open (list dbx $dwg))))
       (prompt "\nOpen failed")
       nil
       )
      (T doc)
      );cond
    )

This all runs fine, assuming I have a valid filename, apart from doc returns nil.

dbx returns an Acad database object (AxDbDocument) rather than a document object (AcadDocument), so I cant use (vla-activate) on this to make it current, thus can't do the line drawing & selection setting etc. I can hopefully work these bits out on my own from googleable stuff, but how to get the Drawing object of the newly opened drawing has me stumped.

Does anyone have any suggestions?

Many thanks in advance.

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Object DBX - open drawing, draw stuff & get selection sets.
« Reply #1 on: July 31, 2015, 02:28:50 PM »
What you want to do, use commands and create selection sets, is not possible with ODBX.
You basically have to work with the database object you have mentioned.
Try using:
Code: [Select]
(vlax-dump-object dataBaseObject T)To get more insight in what is possible.

To add a line in modelspace:
Code: [Select]
(vlax-invoke
  (vla-get-modelspace dataBaseObject)
  'addline
  '(0.0 0.0 0.0)
  '(1.0 0.0 0.0)
)

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Object DBX - open drawing, draw stuff & get selection sets.
« Reply #2 on: July 31, 2015, 07:13:02 PM »
This function gives a brief outline of what functionality is available when operating through an ObjectDBX interface (there are some exceptions of course, on both sides); the page also provides some examples showing how to work with the ObjectDBX Document object, and the code for the function itself demonstrates one possible way to obtain a pointer to the document in the first place.

Hope this helps.

TimAshby

  • Guest
Re: Object DBX - open drawing, draw stuff & get selection sets.
« Reply #3 on: August 04, 2015, 08:21:56 AM »
Thanks for the replies.  I was hoping vla-select was gonna get thro' the restrictions, but I guess it is just another way of addressing / creating a selection set. Alas... Cheers!

TimAshby

  • Guest
Re: Object DBX - open drawing, draw stuff & get selection sets.
« Reply #4 on: August 10, 2015, 07:24:40 AM »
Another question on this topic - can one copy an entity between drawings with ODBX?

I've seen Lee's Steal from Drawing routine, I guess blocks shouldn't be a problem.

Can I get the info from, say, a polyline, or do I have to (vlax-get obj 'Coordinates), & step thro' all the vertices & get the bulge, (& the width etc etc) & stick them in BB-space & then recreate them in a new drawing?

Cheers

« Last Edit: August 10, 2015, 07:30:21 AM by TimAshby »

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Object DBX - open drawing, draw stuff & get selection sets.
« Reply #5 on: August 10, 2015, 09:06:16 AM »
You can just use the copyobjects method:
Code - Auto/Visual Lisp: [Select]
  1.   actDocObj
  2.   'copyobjects
  3.   (list polyObj) ; PolyObj is part of actDocObj.
  4.   (vla-get-modelspace odbxObj)
  5. )