Author Topic: ObjectDBX Xref for block  (Read 19963 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX Xref for block
« Reply #45 on: November 01, 2007, 06:06:44 PM »
Okay.  I see the problem.  It is a dynamic block, so the way I was using will not work.  You will have to search the whole drawing to find the correct block.  You will have to check the property 'EffectiveName' since that is the name of the block before you make any dynamic changes.

Code: [Select]
(vlax-for lo (vla-get-Layouts dbxDoc)
 (vlax-for obj (vla-get-Block lo)
  (if
   (and
    (= (vla-get-ObjectName obj) "AcDbBlockReference")
    (= (strcase (vla-get-EffectiveName obj)) "DETAIL BDR")
   )
   (setq dbxScale (vla-get-XScaleFactor obj))
  )
 )
)
This will replace all of this.
Code: [Select]
  (setq dbxBlocks (vla-get-blocks dbxDoc))
  (setq dbxBlock (vla-item dbxBlocks "Detail Bdr"))
  (setq dbxEname (vlax-vla-object->ename dbxBlock))
  (setq dbxEntData (entget dbxEname))
  (setq dbxBlockInsert (cdr (assoc 331 dbxEntData)))
  (setq dbxScale (cdr (assoc 41 (entget dbxBlockInsert))))
Tim

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

Please think about donating if this post helped you.

OcCad

  • Guest
Re: ObjectDBX Xref for block
« Reply #46 on: November 01, 2007, 06:14:42 PM »
TW: Hmmm... Strange because when I did the test detail/test sheet I spoke to Vovka about the detail was just a drawing containing that dynamic block. But i will try your recent post as well

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX Xref for block
« Reply #47 on: November 01, 2007, 06:17:08 PM »
The problem is when you change the dynamic properties it changes the block to an anonymous block, so it does not really reference the block definition anymore.  It may, but not in the way the old style blocks referenced the block definition.  I just learned that by looking at what you posted since I haven't dug into '08 yet.
Tim

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

Please think about donating if this post helped you.

VovKa

  • Water Moccasin
  • Posts: 1629
  • Ukraine
Re: ObjectDBX Xref for block
« Reply #48 on: November 01, 2007, 06:21:32 PM »
what is a dynamic block? :)
i use autocad 2004, so no dynamic blocks at all :0

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX Xref for block
« Reply #49 on: November 01, 2007, 06:24:07 PM »
what is a dynamic block? :)
i use autocad 2004, so no dynamic blocks at all :0
A dynamic block is a block that change it's appearance.  So if you have blocks that are similar, you can create one block with different views.  They can get real complex, but that is a simple explanation.  Started in '06 I think.
Tim

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

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX Xref for block
« Reply #50 on: November 01, 2007, 06:26:59 PM »
OcCad,
 
  If the block is inserted in paper space, then you have to use ObjectDBX to get this information, but if it is inserted into model space no need to go the ObjectDBX route since all objects in model space are brought over in the xref.  You just need to search the blocks definition for the block you want to check.  This will make the program faster, and won't matter if anyone has the xref'ed drawing open.
Tim

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

Please think about donating if this post helped you.

OcCad

  • Guest
Re: ObjectDBX Xref for block
« Reply #51 on: November 01, 2007, 06:33:40 PM »
thanks guys! And if i wanted to expand the list of blocks to search for, would this be the correct way to do it?

Code: [Select]
    (vlax-for lo (vla-get-Layouts dbxDoc)
     (vlax-for obj (vla-get-Block lo)
      (if
       (and
        (= (vla-get-ObjectName obj) "AcDbBlockReference")
         (if(null (= (strcase (vla-get-EffectiveName obj)) "Detail Bdr"))
          (progn ;else
          (if (null (= (strcase (vla-get-EffectiveName obj)) "Detail Bdr2"))
           (progn ;else
           (= (strcase (vla-get-EffectiveName obj)) "Detail Bdr3")
          );if
         );if
        );and
       (setq dbxScale (vla-get-XScaleFactor obj))
      );if
     )
    )

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX Xref for block
« Reply #52 on: November 01, 2007, 06:42:23 PM »
The way I would do it, is make a list of all the block names you want to search for, and then just test the block name against the list.
Code: [Select]
(vl-position (strcase (vla-get-Name blk)) '("DETAIL BDR" "DETAIL BDR2" "DETAIL BDR3")
Don't forget that lisp is case sensitive (most of the time).

You're welcome.  Hope you learned something along this first journey.
Tim

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

Please think about donating if this post helped you.

OcCad

  • Guest
Re: ObjectDBX Xref for block
« Reply #53 on: November 01, 2007, 06:54:57 PM »
Perfect! Thank you everybody for all your contribution.

Vovka & T. Willey may I get your Names so that I may log it into the lisp

T.Willey

  • Needs a day job
  • Posts: 5251
Re: ObjectDBX Xref for block
« Reply #54 on: November 01, 2007, 07:03:13 PM »
Perfect! Thank you everybody for all your contribution.

Vovka & T. Willey may I get your Names so that I may log it into the lisp
That is my name.  T. = Tim (in the signature) Willey = Willey.  :wink:

Glad you got something that works for you.  Now you should make all your variables local.  Very good idea.
Tim

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

Please think about donating if this post helped you.

OcCad

  • Guest
Re: ObjectDBX Xref for block
« Reply #55 on: November 01, 2007, 07:35:12 PM »
Yeah, I learned that I have a lot to learn  :-D

OcCad

  • Guest
Re: ObjectDBX Xref for block
« Reply #56 on: November 02, 2007, 01:29:49 PM »
Okay, I'm having some trouble with older details and i feel its because of the fact that my detail borders are no longer dynamic blocks

Right now in DBX I'm looking for my desired block like this
Code: [Select]
    (vlax-for LO (vla-get-Layouts dbxDoc)
     (vlax-for Obj (vla-get-Block LO)
      (if
       (and
        (= (vla-get-ObjectName Obj) "AcDbBlockReference")
        (= (vl-position (strcase (vla-get-EffectiveName Obj)) '("Detail Bdr" "DTLTITLE" "DET-TITLE")))
       );and
       (setq dbxScale (vla-get-XScaleFactor Obj))
      ):if
     )
    )
   (princ)

but for some reason with this block even though my effective scale factor is 12.0 it scale my drawing up to 1'-4"=1'-0" (reading an effective scale factor of 0.75). with the properties listed below can you see why?

Code: [Select]
Command: dlist
 Select entity to see all properties and methods:
; IAcadBlockReference: AutoCAD Block Reference Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00d74d3c>
;   Document (RO) = #<VLA-OBJECT IAcadDocument 01b95dc0>
;   EffectiveName (RO) = "DTLTITLE"
;   Handle (RO) = "3045"
;   HasAttributes (RO) = -1
;   HasExtensionDictionary (RO) = 0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0f96c49c>
;   InsertionPoint = (51.6009 22.2771 0.0)
;   InsUnits (RO) = "Unitless"
;   InsUnitsFactor (RO) = 1.0
;   IsDynamicBlock (RO) = 0
;   Layer = "TITLINE"
;   Linetype = "BYLAYER"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   Name = "MSMTITLE"
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 2105865832
;   ObjectName (RO) = "AcDbBlockReference"
;   OwnerID (RO) = 2107587600
;   PlotStyleName = "ByLayer"
;   Rotation = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 0f952410>
;   Visible = -1
;   XEffectiveScaleFactor = 12.0
;   XScaleFactor = 12.0
;   YEffectiveScaleFactor = 12.0
;   YScaleFactor = 12.0
;   ZEffectiveScaleFactor = 12.0
;   ZScaleFactor = 12.0
; Methods supported:
;   ArrayPolar (3)
;   ArrayRectangular (6)
;   ConvertToAnonymousBlock ()
;   ConvertToStaticBlock (1)
;   Copy ()
;   Delete ()
;   Explode ()
;   GetAttributes ()
;   GetBoundingBox (2)
;   GetConstantAttributes ()
;   GetDynamicBlockProperties ()
;   GetExtensionDictionary ()
;   GetXData (3)
;   Highlight (1)
;   IntersectWith (2)
;   Mirror (2)
;   Mirror3D (3)
;   Move (2)
;   ResetBlock ()
;   Rotate (2)
;   Rotate3D (3)
;   ScaleEntity (2)
;   SetXData (2)
;   TransformBy (1)
;   Update ()

Bob Wahr

  • Guest
Re: ObjectDBX Xref for block
« Reply #57 on: November 02, 2007, 01:41:01 PM »
Is the block annotative?

VovKa

  • Water Moccasin
  • Posts: 1629
  • Ukraine
Re: ObjectDBX Xref for block
« Reply #58 on: November 02, 2007, 01:53:27 PM »
not
Code: [Select]
(= (vl-position (strcase (vla-get-EffectiveName Obj)) '("Detail Bdr" "DTLTITLE" "DET-TITLE")))
but
Code: [Select]
(vl-position (strcase (vla-get-EffectiveName Obj)) '("DETAIL BDR" "DTLTITLE" "DET-TITLE"))
« Last Edit: November 02, 2007, 02:02:13 PM by VovKa »

OcCad

  • Guest
Re: ObjectDBX Xref for block
« Reply #59 on: November 02, 2007, 01:59:24 PM »
But I thought Lisp was cAsE sensitive... And in our dynamic block "Detail Bdr" thats how it lists