Dbx new Layer

Discussion in 'AutoCAD' started by Rudy Tovar, Dec 28, 2004.

  1. Rudy Tovar

    Rudy Tovar Guest

    Trying to create a new layer in a drawing I'm opening using dbx....and get
    the following for object...

    ; IAcadLayer2: A logical grouping of data, similar to transparent acetate

    overlays on a drawing
     
    Rudy Tovar, Dec 28, 2004
    #1
  2. Rudy Tovar

    Rudy Tovar Guest

    Should have worked huh?

    Or is it not possible, and I'm running around in circles, or perhaps I made
    a boo boo....
     
    Rudy Tovar, Dec 28, 2004
    #2
  3. What doesn't work, Rudy? I don't follow, given
    the two posts thus far. Please explain.
     
    Jason Piercey, Dec 28, 2004
    #3
  4. Rudy Tovar

    Jeff Mishler Guest

    Post the code you are creating the layer with? Acad version? The description
    seems to be consistent with what a layer is......
     
    Jeff Mishler, Dec 28, 2004
    #4
  5. Rudy Tovar

    Rudy Tovar Guest

    Here's the code...don't forget, I'm still testing so don't pay attention to
    the fact I didn't use 'cond' etc.

    (vl-load-com)

    (defun c:fixd (/ dir)
    (IF (AND (NOT (VL-REGISTRY-READ
    "HKEY_CLASSES_ROOT\\ObjectDBX.AxDbDocument.16\\CLSID"))
    (FINDFILE "axdb16.dll")
    )
    (STARTAPP "regsvr32.exe" (STRCAT "/s \"" (FINDFILE "axdb16.dll")
    "\""))
    )
    (setq dir (getfiled "Select Directory To Process" ""dwg" 4))

    ;(prompt dir)
    (dbxblock dir)
    (princ)
    )

    ; Filter object ;
    ;================================;
    ; Text ;
    ; Leader ;
    ; Lines ;
    ; Hatch ;
    ; Dimensions ;
    ;

    ; Layers ;
    ;================================;
    ; a-detl-note ;
    ; a-detl-dims ;
    ; a-detl ;
    ; a-detl-patt ;
    ;
    ; check hatch pattern scale ;
    ;================================;
    ; earth ;
    ; sand ;
    ; door grain ;
    ; conc. ;
    ; gyp. ;
    ; etc. ;



    (defun dbxblock (dwgname / dbxDoc for-item name layer llist ob)

    (if dwgname
    (progn
    (setq dbxDoc
    (vla-GetInterfaceObject
    (vlax-get-acad-object)
    "ObjectDBX.AxDbDocument.16"; MUST reference autocad DBX version
    )
    )
    (vla-open dbxDoc DwgName)

    ;(fixd-setup-dwg dbxdoc)



    (vlax-for layer (vla-get-layers dbxdoc)
    (progn
    (setq llist (cons (strcase (vla-get-name layer)) llist))
    )
    )

    ; Layers ;
    ;================================;
    ; a-detl-note ;
    ; a-detl-dims ;
    ; a-detl ;
    ; a-detl-patt ;


    (if (= (vl-position "A-DETL" llist) nil)
    (progn
    (setq ob (vla-add (vla-get-layers dbxdoc) "A-DETL"))
    (vla-put-description ob "DETAIL SECTION CUT")
    )
    )
    (if (= (vl-position "A-DETL-NOTE" llist) nil)
    (progn
    (setq ob (vla-add (vla-get-layers dbxdoc) "A-DETL-NOTE"))
    (vla-put-description ob "DETAIL NOTES")
    )
    )
    (if (= (vl-position "A-DETL-DIMS" llist) nil)
    (progn
    (setq ob (vla-add (vla-get-layers dbxdoc) "A-DETL-DIMS"))
    (vla-put-description ob "DETAIL DIMENSION")
    )
    )
    (if (= (vl-position "A-DETL-PATT" llist) nil)
    (progn
    (setq ob (vla-add (vla-get-layers dbxdoc) "A-DETL-PATT"))
    (vla-put-description ob "DETAIL HATCH PATTERN")
    )
    )





    (vlax-for for-item (vla-get-modelspace dbxDoc)
    (progn ; start of object cycle



    (setq name (vla-get-objectname for-item))

    (if
    (or
    (= name "AcDbArc")
    (= name "AcDbLine")
    (= name "AcDbCircle")
    (= name "AcDbPolyline")
    )
    (progn
    ;Conditions
    )
    )

    (if
    (or
    (= name "AcDbText")
    (= name "AcDbLeader")
    )
    (progn


    ;Conditions
    )
    )

    (if
    (= name "AcDbHatch")
    (progn
    ;Conditions
    )
    )

    (if
    (= name "AcDbBlockReference")
    (progn
    ;Conditions
    )
    )

    (if
    (= name "AcDbRotatedDimension")
    (progn
    ;Conditions
    )
    )





    ); end of object cycle
    ) ; end of progn of all objects in modelspace

    (vl-catch-all-apply
    '(lambda () (vla-close DBXDOC ':VLAX-TRUE 'ITEM))
    )

    (VL-CATCH-ALL-APPLY
    'vlax-release-object
    (list dbxDoc dwgname for-item name layer llist ob)

    )
    (vlax-release-object dbxDoc)

    (setq dbxDoc nil)
    )
    )
    (princ)
    )
     
    Rudy Tovar, Dec 28, 2004
    #5
  6. Rudy Tovar

    Jeff Mishler Guest

    OK, just for grins I ran a quick test here in R2002. I get similar feedback,
    but the layer is created......

    #<VLA-OBJECT IAxDbDocument 0167b838>
    _$

    nil
    _$

    #<VLA-OBJECT IAcadLayer 057c72f4>
    _$

    ; IAcadLayer: A logical grouping of data, similar to transparent acetate
    overlays on a drawing
    ; Property values:
    ; Application (RO) = Exception occurred
    ; Color = 7
    ; Document (RO) = #<VLA-OBJECT IAxDbDocument 0167b838>
    ; Freeze = 0
    ; Handle (RO) = "4B"
    ; HasExtensionDictionary (RO) = 0
    ; LayerOn = -1
    ; Linetype = "Continuous"
    ; Lineweight = -3
    ; Lock = 0
    ; Name = "NewTest4Rudy"
     
    Jeff Mishler, Dec 28, 2004
    #6
  7. Rudy Tovar

    Rudy Tovar Guest

    Was it created in the dwg file that was accessed via the dbx function?
     
    Rudy Tovar, Dec 28, 2004
    #7
  8. Rudy Tovar

    Rudy Tovar Guest

    Oh, and it's 2005..

     
    Rudy Tovar, Dec 28, 2004
    #8
  9. Rudy Tovar

    Jeff Mishler Guest

    Yes, it was saved. I went through your code and the problem is being covered
    up by your use of (vlax-catch-all-apply). ObjectDBX doc's don't support the
    Close method. It reports having a Save method, but it does not work either.
    To save changes to a DBX doc, use the SaveAs method.....:

    (vla-saveas dbxdoc dwgname)
     
    Jeff Mishler, Dec 28, 2004
    #9
  10. Rudy Tovar

    Rudy Tovar Guest

    AHHHH!!! I knew I forgot something....AAHAHAHHHAA

    I'm about ready to pull my hair out!!!

    Thank you Jeff....

    Just so you know I'm slapping myself silly....
     
    Rudy Tovar, Dec 28, 2004
    #10
  11. Yep, that is correct. Haven't registered anything
    and my objectdbx functions work like they are
    supposed to.
     
    Jason Piercey, Dec 28, 2004
    #11
  12. Rudy Tovar

    MP Guest

    I thought with 2005 you didn't need to register dbx anymore.
    ?
    Mark
     
    MP, Dec 28, 2004
    #12
  13. Rudy Tovar

    Rudy Tovar Guest

    And autocad is suppose to be full proof....yeah right...

    You never know...
     
    Rudy Tovar, Dec 28, 2004
    #13
  14. Rudy,

    Who said AutoCAD is "fool proof" ?

    Register the dbx services all you want, you don't have to.
     
    Jason Piercey, Dec 28, 2004
    #14
  15. interesting.
    I gave him the register code because I do it for A2k...
    thx for the input

    "Jason Piercey" <Jason AT atreng DOT com>
    |>Rudy,
    |>
    |>Who said AutoCAD is "fool proof" ?
    |>
    |>Register the dbx services all you want, you don't have to.

    James Maeding
    jmaeding at hunsaker dot com
    Civil Engineer/Programmer
     
    James Maeding, Dec 28, 2004
    #15
  16. AFAIK, pre-A2K5 the services must be registered.
    (skipped A2K4, so not exactly sure there)
     
    Jason Piercey, Dec 28, 2004
    #16
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.