Author Topic: Make Sheet Index using obectDBX  (Read 67975 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Make Sheet Index using obectDBX
« on: February 09, 2006, 02:19:58 PM »
Please don't think of me as being too lazy, but has anyone know of an objectDBX routine that that will extract an attribute with two values.
I want to be able to select a directory of drawings and get two values from an attributed block from each drawing to compile a lst for asheet index.
ex: value one  = A1.00 (sheet number)
     value two = Cover Sheet (sheet title)

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make Sheet Index using obectDBX
« Reply #1 on: February 09, 2006, 02:48:26 PM »
All you need is the block name and the two attributes tags you want.  Seach the space where the block should be inserted, if you don't know that, then search all the layout spaces.  To do this with ObjectDBX you will have to use the ActiveX controls.  Is this enough to get you started?  What part of the code do you have already?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #2 on: February 09, 2006, 03:15:14 PM »
Tim

I have not made up my mind which way to go. I like Peter Jamtgaard's DBXTX routine and I like your DBX-BlockCopy.lsp routine.
Where i need help is extracing the two attributes values from each sheet and compiling them into a list.

I have heard of a routine out there that is similar to this....at least to get me going.

Here is Peter's routine (uncompiled).

Would I start with this?
Code: [Select]
;;; Extract attribute value given Block object and Tagstring
(defun CODE:GET_ATTVAL (EOBJ TAG / ATTOBJ STR)
  (vl-load-com)
  (if (= (type EOBJ) 'ename)
    (setq EOBJ (vlax-ename->vla-object EOBJ))
  )
  (if (and (= (type EOBJ) 'vla-object)
   (= (vla-get-hasattributes EOBJ) :vlax-true)
      )
    (progn
      (foreach
ATTOBJ
      (vlax-safearray->list
(variant-value
  (vla-getattributes EOBJ)
)
      )
(if (= (strcase (vla-get-tagstring ATTOBJ))
       (strcase TAG)
    )
  (setq STR (vla-get-textstring ATTOBJ))
)
      )
    )
  )
  (if (not STR)
    (setq STR "")
  )
  STR
)

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make Sheet Index using obectDBX
« Reply #3 on: February 09, 2006, 03:25:46 PM »
Here is code that will search the whole drawing, and return a list of block objects that match the block name supplied.
Code: [Select]
(defun GetBlockList (Doc BlkName / BlkList)

(vlax-for LO (vla-get-Layouts Doc)
 (vlax-for Obj (vla-get-Block LO)
  (if
   (and
    (= (vla-get-ObjectName Obj) "AcDbBlockReference")
    (= (strcase (vla-get-Name Obj)) (strcase BlkName))
   )
   (setq BlkList (cons Obj BlkList))
  )
 )
)
BlkList
)
Now all you have to do is get the correct attributes to extract the inforamation you want.
Code: [Select]
(defun GetAttValues (BlkObj TagList / ValueList)

(foreach Att (vlax-invoke BlkObj 'GetAttributes)
 (if (vl-position (setq tmpTag (vla-get-TagString Att)) TagList)
  (setq ValueList (cons (cons tmpTag (vla-get-TextString Att)) ValueList))
 )
)
ValueList
)
Untested, but should work.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #4 on: February 09, 2006, 03:29:50 PM »
Thanks Tim. I will work on it tonight.
I got a lot broken links in my google search...searching for objectdbx attrubute

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Make Sheet Index using obectDBX
« Reply #5 on: February 09, 2006, 03:40:09 PM »
Gary,
See if this will do what you want....or at least get you close.
Code: [Select]
;|function to extract 2 attribute values from a specific block in the drawings of a specified folder
  by Jeff Mishler Feb. 9, 2006 |;
(defun getindex (blkname attname1 attname2 / *acad atts dwgs f folder layouts masterlist name odbx val1 val2)
  (defun BrowseForFolder (/ sh folder parentfolder folderobject result)
    ;;as posted the autodesk discussion customization group by Tony Tanzillo
    (vl-load-com)
    (setq sh
   (vla-getInterfaceObject
     (vlax-get-acad-object)
     "Shell.Application"
   )
    )

    (setq folder
   (vlax-invoke-method
     sh 'BrowseForFolder 0 "" 0)
    )
    (vlax-release-object sh)

    (if folder
      (progn
(setq parentfolder
       (vlax-get-property folder 'ParentFolder)
)
(setq FolderObject
       (vlax-invoke-method
ParentFolder
'ParseName
(vlax-get-property Folder 'Title)
       )
)
(setq result
       (vlax-get-property FolderObject 'Path)
)
(mapcar 'vlax-release-object
(list folder parentfolder folderobject)
)
result
      )
    )
  )
  (defun getdwglist (folderlist)
    (apply 'append
   (mapcar '(lambda (f)
      (mapcar '(lambda (name)
(strcat f "\\" name)
       )
      (vl-directory-files f "*.dwg" 1)
      )
    )
   folderlist
   )
    )
  )
  (if (and (setq *acad (vlax-get-acad-object))
   (setq folder (browseforfolder))
   (setq dwgs (getdwglist (list folder)))
      )
    (progn
      (setq
odbx (if (< (atoi (substr (getvar "acadver") 1 2)) 16)
       (vla-GetInterfaceObject *acad "ObjectDBX.AxDbDocument")
       (vla-GetInterfaceObject
*acad
"ObjectDBX.AxDbDocument.16"
       )
     )
      )
      (foreach dwg dwgs
(if
  (and
    (not (vl-catch-all-error-p
   (vl-catch-all-apply
     '(lambda ()
(vla-open odbx dwg)
      )
   )
)
    )
;see if the block is even in the drawing
    (not
      (vl-catch-all-error-p
(vl-catch-all-apply
  '(lambda ()
     (setq blk (vla-item (vla-get-blocks odbx) blkname))
   )
)
      )
    )
  )
   (progn
     ;;it is...carry on
     (setq layouts (vla-get-layouts odbx))
     (vlax-for layout layouts
       (if (not (eq "MODEL" (strcase (vla-get-name layout))))
(progn
   (vlax-for ent (vla-get-block layout)
     (if (and (eq (vla-get-objectname ent)
  "AcDbBlockReference"
      )
      (eq (strcase (vla-get-name ent))
  (strcase blkname)
      )
)
       (progn
(setq atts (vlax-invoke ent 'getattributes))
(foreach att atts
   (if (eq (vla-get-tagstring att)
   (strcase attname1)
       )
     (setq val1 (vla-get-textstring att))
   )
   (if (eq (vla-get-tagstring att)
   (strcase attname2)
       )
     (setq val2 (vla-get-textstring att))
   )
)
(setq masterlist
(cons (cons val1 val2) masterlist)
;(cons (list (vla-get-name odbx) (cons val1 val2)) masterlist);for testing
)
       )
     )
   )
)
       )
     )
   )
)
      )
      (mapcar 'vlax-release-object (list odbx *acad))
    )
  )
  (reverse masterlist)
)
;;;Test with my title block
(defun c:createindex ()
  (setq indexlist (getindex "TDG" "NO" "SHEET_NAME"))
)

This returns:
(("1" . "TITLE SHEET") ("2" . "NOTES AND SECTIONS") ("3" . "GRADING PLAN") ("4"
. "IMPROVEMENT PLAN") ("5" . "PROFILES") ("6" . "PINER ROAD X-SECTIONS") ("7" .
"SIGNING, LIGHTING AND STRIPING PLAN") ("8" . "EROSION CONTROL PLAN") ("9" .
"OFFSITE STORM DRAIN IMPROVEMENT PLAN"))

Edit: Added the returned value and changed the return from the function to be (reverse masterlist)
« Last Edit: February 09, 2006, 03:53:27 PM by Jeff_M »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Make Sheet Index using obectDBX
« Reply #6 on: February 09, 2006, 03:42:27 PM »
Just know that when you use ObjectDBX you can't use any ssget stuff.  You have to use the ActiveX controls to step though the document, and make sure that you release it.  Jeff wrote an article about ObjectDBX, and I think it is here.  Just do an advance search, with the author Jeff_M and then ObjectDBX, and you should come up with some good stuff.

Jeff beat me to the punch, but I still want to post what I typed.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Make Sheet Index using obectDBX
« Reply #7 on: February 09, 2006, 03:49:16 PM »
Gary,
See if this will do what you want....or at least get you close.
........

I reckon that'd be pretty close :-)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #8 on: February 09, 2006, 04:12:05 PM »
Thanks Jeff

Man how do you guys learn this stuff?

All I see is vla-blahblahblah.........I am going to have learn this.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #9 on: February 09, 2006, 04:33:31 PM »
Jeff

THANK YOU

I just realized that you had a complete routine!

This is my rusetls from your routine:
Code: [Select]
(("A0.00" . "Cover") ("A0.01" . "Site Plan") ("A1.01" . "Project Data")
("A1.02a" . "Fire Proofing Data") ("A1.02b" . "Fire Proofing Data") ("A1.02c" .
"Fire Proofing Data") ("A1.03" . "Fair Housing Data") ("A1.04" . "TAS Handicap
Data") ("A1.05" . "TAS Handicap Data") ("A2.00a" . "Foundation Layout Plan")
("A2.00b" . "First Floor Layout Plan") ("A2.00c" . "Second Floor Layout Plan")
("A2.00d" . "Third Floor Layout Plan") ("A2.00e" . "Roof Layout Plan")
("A2.01a" . "Foundation Plan Bldg I") ("A2.01b" . "First Floor Plan Bldg I")
("A2.01c" . "Second Floor Plan Bldg I") ("A2.01d" . "Third Floor Plan Bldg I")
("A2.01e" . "Roof Plan Bldg I") ("A2.02a" . "Foundation Plan Bldg II")
("A2.02b" . "First Floor Plan Bldg II") ("A2.02c" . "Second Floor Bldg II")
("A2.02d" . "Third Floor Plan Bldg II") ("A2.02e" . "Roof Plan Bldg II")
("A3.00" . "Schedules") ("A3.01" . "Unit Plan A2") ("A3.02a" . "Unit Plan A3")
("A3.02b" . "Unit Plan A3 HC") ("A3.03" . "Unit Plan B1") ("A3.04a" . "Unit
Plan B3") ("A3.04b" . "Unit Plan B3 HC") ("A4.01" . "Building Elevations")
("A4.02" . "Building Elevations") ("A4.03" . "Building Elevations") ("A4.04" .
"Building Elevations") ("A4.05" . "Building Elevations") ("A4.06" . "Building
Elevations") ("A5.01" . "Wall Section") ("A5.02" . "Wall Section") ("A5.03" .
"Wall Section") ("A5.04" . "Wall Section") ("A6.01" . "Stair Plans") ("A6.02" .
"Elevator") ("A6.03" . "Enlarged Plans") ("A6.04" . "Stair Sections") ("A6.05"
. "Stair Sections") ("A7.01" . "Detail") ("A7.02" . "Details") ("A7.03" .
"Details") ("A7.04" . "Details") ("A7.05" . "Details") ("A7.06" . "Details")
("A7.06" . "Details") ("A7.06" . "Details") ("A7.07" . "Details") ("A8.01a" .
"Foundation Plan Club") ("A8.01b" . "First Floor Plan Club") ("A8.01c" .
"Second Floor Plan Club") ("A8.01d" . "Third Floor Plan Club") ("A8.01e" .
"Roof Plan Club") ("A8.02a" . "First Floor RCP Club") ("A8.02b" . "Second Floor
RCP Club") ("A8.02c" . "Third Floor RCP Club") ("A8.03" . "Elevations")
("A8.04" . "Elevations - Bldg Sections") ("A8.05" . "Enlarged Plans") ("A8.06"
. "Wall Section") ("A8.07" . "Wall Section") ("A8.08" . "Wall Section")
("A9.01" . "Maintenance") ("A9.02" . "Trash"))

Gary (I'm in your debt)
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Jeff_M

  • King Gator
  • Posts: 4087
  • C3D user & customizer
Re: Make Sheet Index using obectDBX
« Reply #10 on: February 09, 2006, 04:46:42 PM »
You're welcome! Your request for this rekindled an idea I had about a year ago that I shelved for lack of time....and promptly forgot about.

Just out of curiosity, what is a "rusetls"? A new type of potato?  :lmao: :kewl:

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #11 on: February 09, 2006, 04:52:02 PM »
Really, I speak better than I type.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #12 on: February 09, 2006, 05:48:01 PM »
Jeff

Here is a modified version:

Code: [Select]
code:
(defun c:CreateIndex (/ indexlist)
  (setq indexlist (getindex "2436TBA" "A-01" "SHT_TTL"))
  (princ "\n")
  (repeat
    (length indexlist)
    (setq a (car indexlist) indexlist (cdr indexlist))
    (princ (car a))
    (princ "\t")
    (princ (cdr a))
    (princ "\n")
  )
)

Results:
A0.00      Cover
A0.01      Site Plan
A1.01      Project Data
A1.02a       Fire Proofing Data
A1.02b       Fire Proofing Data
A1.02c       Fire Proofing Data
A1.03      Fair Housing Data
A1.04      TAS Handicap Data
A1.05      TAS Handicap Data
A2.00a       Foundation Layout Plan
A2.00b       First Floor Layout Plan
A2.00c       Second Floor Layout Plan
A2.00d       Third Floor Layout Plan
A2.00e       Roof Layout Plan
A2.01a       Foundation Plan Bldg I
A2.01b       First Floor Plan Bldg I
A2.01c       Second Floor Plan Bldg I
A2.01d       Third Floor Plan Bldg I
A2.01e       Roof Plan Bldg I
A2.02a       Foundation Plan Bldg II
A2.02b       First Floor Plan Bldg II
A2.02c       Second Floor Bldg II
A2.02d       Third Floor Plan Bldg II
A2.02e       Roof Plan Bldg II
A3.00      Schedules
A3.01      Unit Plan A2
A3.02a       Unit Plan A3
A3.02b       Unit Plan A3 HC
A3.03      Unit Plan B1
A3.04a       Unit Plan B3
A3.04b       Unit Plan B3 HC
A4.01      Building Elevations
A4.02      Building Elevations
A4.03      Building Elevations
A4.04      Building Elevations
A4.05      Building Elevations
A4.06      Building Elevations
A5.01      Wall Section
A5.02      Wall Section
A5.03      Wall Section
A5.04      Wall Section
A6.01      Stair Plans
A6.02      Elevator
A6.03      Enlarged Plans
A6.04      Stair Sections
A6.05      Stair Sections
A7.01      Detail
A7.02      Details
A7.03      Details
A7.04      Details
A7.05      Details
A7.06      Details
A7.06      Details
A7.06      Details
A7.07      Details
A8.01a       Foundation Plan Club
A8.01b       First Floor Plan Club
A8.01c       Second Floor Plan Club
A8.01d       Third Floor Plan Club
A8.01e       Roof Plan Club
A8.02a       First Floor RCP Club
A8.02b       Second Floor RCP Club
A8.02c       Third Floor RCP Club
A8.03      Elevations
A8.04      Elevations - Bldg Sections
A8.05      Enlarged Plans
A8.06      Wall Section
A8.07      Wall Section
A8.08      Wall Section
A9.01      Maintenance
A9.02      Trash

Thank you again.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Make Sheet Index using obectDBX
« Reply #13 on: February 09, 2006, 06:04:20 PM »
Jeff

FYI

You can place in a string value for a titlle in the BrowseForFolder:

(setq folder
      (vlax-invoke-method
        sh   'BrowseForFolder 0 (strcat "Jeff Mishler's" " : Select Drawings Folder for Sheet Index") 0)
    )

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Make Sheet Index using obectDBX
« Reply #14 on: February 09, 2006, 06:19:13 PM »
Gary,
Try this for formatting.

Code: [Select]
(defun c:createindex (/ indexlist)
   (defun padout (word len / spaces)
    (repeat (- len (strlen word)) (setq spaces (cons 32 spaces)))
    (strcat word (vl-list->string spaces))
  )
  (setq indexlist (getindex "2436TBA" "A-01" "SHT_TTL"))
  (foreach itm indexlist
    (princ "\n")
    (princ (strcat (padout (car itm) 12) (cdr itm)))
  )
  (princ)
)
« Last Edit: February 09, 2006, 07:26:14 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.