<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Access to Civil 3D Objects via Object DBX? in Civil 3D Customization Forum</title>
    <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/access-to-civil-3d-objects-via-object-dbx/m-p/13384266#M218</link>
    <description>&lt;P&gt;Yeah, turns out the surface objects exist and can be accessed via model space&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_head_bandage:"&gt;🤕&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Mar 2025 20:51:34 GMT</pubDate>
    <dc:creator>CodeDing</dc:creator>
    <dc:date>2025-03-21T20:51:34Z</dc:date>
    <item>
      <title>Access to Civil 3D Objects via Object DBX?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/access-to-civil-3d-objects-via-object-dbx/m-p/13384092#M215</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone know of a way (or if it's even possible) to access Civil 3D objects (specifically TIN Surfaces) via Object DBX? (So I do not have to open the DWG file)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know we can get the&amp;nbsp;IAxDbDocument like this, but it does not give access to C3D objects:&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;(setq acadDBX (vlax-create-object (strcat "ObjectDBX.AxDbDocument." (substr (getvar 'acadver) 1 2))))
(vla-open acadDBX "C:\\users\\me\\test.dwg")
(vlax-dump-object acadDBX t)
(vlax-release-object acadDBX)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;; IAxDbDocument: IAxDbDocument Interface
; Property values:
;   Application (RO) = Class not registered
;   Blocks (RO) = #&amp;lt;VLA-OBJECT IAcadBlocks 0000021fdf99bec8&amp;gt;
;   Database (RO) = #&amp;lt;VLA-OBJECT IAcadDatabase 0000021ff4ae8428&amp;gt;
;   Dictionaries (RO) = #&amp;lt;VLA-OBJECT IAcadDictionaries 0000021fdf99c198&amp;gt;
;   DimStyles (RO) = #&amp;lt;VLA-OBJECT IAcadDimStyles 0000021fdf99bf58&amp;gt;
;   ElevationModelSpace = 0.0
;   ElevationPaperSpace = 0.0
;   Groups (RO) = #&amp;lt;VLA-OBJECT IAcadGroups 0000021fdf99bfe8&amp;gt;
;   Layers (RO) = #&amp;lt;VLA-OBJECT IAcadLayers 0000021fdf99c468&amp;gt;
;   Layouts (RO) = #&amp;lt;VLA-OBJECT IAcadLayouts 0000021fdf99b388&amp;gt;
;   Limits = (0.0 0.0 12.0 9.0)
;   Linetypes (RO) = #&amp;lt;VLA-OBJECT IAcadLineTypes 0000021fdf99b9b8&amp;gt;
;   Materials (RO) = #&amp;lt;VLA-OBJECT IAcadMaterials 0000021fdf99a218&amp;gt;
;   ModelSpace (RO) = #&amp;lt;VLA-OBJECT IAcadModelSpace 0000021fb21d1e68&amp;gt;
;   Name = "C:\\users\\me\\test.dwg"
;   PaperSpace (RO) = #&amp;lt;VLA-OBJECT IAcadPaperSpace 0000021fb21d20e8&amp;gt;
;   PlotConfigurations (RO) = #&amp;lt;VLA-OBJECT IAcadPlotConfigurations 0000021fdf99bad8&amp;gt;
;   Preferences (RO) = #&amp;lt;VLA-OBJECT IAcadDatabasePreferences 0000021fe51624e8&amp;gt;
;   RegisteredApplications (RO) = #&amp;lt;VLA-OBJECT IAcadRegisteredApplications 0000021fdf99a578&amp;gt;
;   SectionManager (RO) = Exception occurred
;   SummaryInfo (RO) = #&amp;lt;VLA-OBJECT IAcadSummaryInfo 0000021ff4ae7ed8&amp;gt;
;   TextStyles (RO) = #&amp;lt;VLA-OBJECT IAcadTextStyles 0000021fdf99b028&amp;gt;
;   UserCoordinateSystems (RO) = #&amp;lt;VLA-OBJECT IAcadUCSs 0000021fdf99b0b8&amp;gt;
;   Viewports (RO) = #&amp;lt;VLA-OBJECT IAcadViewports 0000021fdf99b148&amp;gt;
;   Views (RO) = #&amp;lt;VLA-OBJECT IAcadViews 0000021fdf99b4a8&amp;gt;
; Methods supported:
;   CopyObjects (3)
;   DxfIn (2)
;   DxfOut (3)
;   HandleToObject (1)
;   ObjectIdToObject (1)
;   Open (2)
;   Save ()
;   SaveAs (2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated!&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Fri, 21 Mar 2025 18:44:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/access-to-civil-3d-objects-via-object-dbx/m-p/13384092#M215</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2025-03-21T18:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Access to Civil 3D Objects via Object DBX?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/access-to-civil-3d-objects-via-object-dbx/m-p/13384221#M216</link>
      <description>&lt;P&gt;In your DBX document, what happens if you iterate the ModelSpace block entities, filtering for the desired ObjectName(s)?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Mar 2025 20:23:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/access-to-civil-3d-objects-via-object-dbx/m-p/13384221#M216</guid>
      <dc:creator>BlackBox_</dc:creator>
      <dc:date>2025-03-21T20:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: Access to Civil 3D Objects via Object DBX?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/access-to-civil-3d-objects-via-object-dbx/m-p/13384224#M217</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5680873"&gt;@CodeDing&lt;/a&gt;&amp;nbsp;it has been 15, or so, years since I attempted this. I am not seeing anything in my old lisp code snips suggesting that I ever succeeded. This may be due to that was about when I started mingling heavily into the .NET API and found it is very easy to access the C3D objects in an external database.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Mar 2025 20:25:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/access-to-civil-3d-objects-via-object-dbx/m-p/13384224#M217</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2025-03-21T20:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Access to Civil 3D Objects via Object DBX?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/access-to-civil-3d-objects-via-object-dbx/m-p/13384266#M218</link>
      <description>&lt;P&gt;Yeah, turns out the surface objects exist and can be accessed via model space&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_head_bandage:"&gt;🤕&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Mar 2025 20:51:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/access-to-civil-3d-objects-via-object-dbx/m-p/13384266#M218</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2025-03-21T20:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Access to Civil 3D Objects via Object DBX?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/access-to-civil-3d-objects-via-object-dbx/m-p/13384335#M219</link>
      <description>&lt;P&gt;For any future wanderers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goal was to extract the Latitudes and Longitudes of any existing surfaces in some external drawings.&lt;/P&gt;&lt;P&gt;That can be quite a nuisance because you need to be sure a coordinate system is assigned within the source drawing (hopefully whoever assigned it made sure it was the right one and scaled if necessary).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code opens a DBX document, ensures that is has a coordinate system, retrieves the coordinate system ID, gets the borders of all surfaces (sometimes surface can have multiple borders), then attempts to turn the border coordinates into Latitudes/Longitudes (this is only possible if you have the coordinate system id in your current coordinate system database file (.cs file)).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best of luck, it's not the cleanest code, but it gets it done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;STRONG&gt;EDIT:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;STRONG&gt;FYI, the (alx-parse-xml2lisp ...) function is from some custom functions [ALx Functions] I made a while back:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-extended-alx-functions/m-p/10170619/highlight/true#M412778" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/autolisp-extended-alx-functions/m-p/10170619/highlight/true#M412778&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;STRONG&gt;...it parses XML to Lisp, so I can retrieve items easier; HOWEVER, I have not created a new version for AutoCAD 2025+ yet. So ALX functions currently do not work with 2025+&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;;; Gets surface borders of all surfaces in doc
;; doc - vla-obj, the DBX document
;; returns - list, of all surfaces and borders in x/y, like:
;; (
;;   ("Surface1"
;;     ((&amp;lt;x&amp;gt; &amp;lt;y&amp;gt;) (&amp;lt;x&amp;gt; &amp;lt;y&amp;gt;) ...)
;;     ((&amp;lt;x&amp;gt; &amp;lt;y&amp;gt;) (&amp;lt;x&amp;gt; &amp;lt;y&amp;gt;) ...)
;;     ...
;;   )
;;   ("Surface2"
;;     ((&amp;lt;x&amp;gt; &amp;lt;y&amp;gt;) (&amp;lt;x&amp;gt; &amp;lt;y&amp;gt;) ...)
;;     ((&amp;lt;x&amp;gt; &amp;lt;y&amp;gt;) (&amp;lt;x&amp;gt; &amp;lt;y&amp;gt;) ...)
;;     ...
;;   )
;; )
(defun GetSurfaces (doc / ms cnt n surfs borders return)
  (setq ms (vlax-get doc 'ModelSpace))
  (if (and (not (zerop (setq cnt (vlax-get ms 'Count))))
           (progn (setq n -1)
                  (repeat cnt
                    (if (eq "AeccDbSurfaceTin" (vlax-get (setq item (vlax-invoke ms 'Item (setq n (1+ n)))) 'ObjectName))
                      (setq surfs (cons item surfs))
                    );if
                    surfs
                  );repeat
           );progn
      );and
    (progn
      (foreach surf surfs
        (setq borders (vlax-invoke surf 'ExtractBorder 1))
        (setq return
          (cons
            (cons (vlax-get surf 'Name)
                  (mapcar
                    '(lambda (b / coords coordList)
                      (setq coords (vlax-get b 'Coordinates))
                      (while coords
                        (setq coordList
                          (cons (list (car coords) (cadr coords)) coordList)
                        );setq
                        (setq coords (cdddr coords))
                      );while
                      (reverse coordList)
                    );lambda
                    borders
                  );mapcar
            );cons
            return
          );cons
        );setq
      );foreach
      return
    );progn
  );if
);defun

;; Ensures DBX doc has coordinate system, retrieves name if so
;; doc - vla-obj, DBX document
;; returns - string, of coordinate system ID
(defun GetCoordSys (doc / ms ed geoData MultiAssoc xml csData)
  (setq ms (vlax-get doc 'ModelSpace))
  (setq ed (vlax-invoke ms 'GetExtensionDictionary))
  (if (not
        (vl-catch-all-error-p
          (setq geoData
            (vl-catch-all-apply 'vlax-invoke (list ed 'GetObject "ACAD_GEOGRAPHICDATA"))
          )
        )
      )
    (progn
      (setq MultiAssoc (lambda (k l / i) (if (setq i (assoc k l)) (cons (cdr i) (MultiAssoc k (cdr (member i l)))))))
      (setq geoData (entget (vlax-vla-object-&amp;gt;ename geoData)))
      (setq xml (strcat (apply 'strcat (MultiAssoc 303 geoData)) (cdr (assoc 301 (reverse geoData)))))
      (setq csData (alx-parse-xml2lisp xml))
      (cdr (assoc "Name" (cdr (assoc "ProjectedCoordinateSystem" (cdr (assoc "Dictionary" csData))))))
    );progn
  );if
);defun

;; MAIN FUNCTION
;; Retrieves Border from all TIN surfaces inside provided dwg file
;; filename - string, of full file path
;; returns - list, of all boundaries in lat/long (surfaces can have multiple), like:
;; (
;;   ("Surface1"
;;     ((&amp;lt;lon&amp;gt; &amp;lt;lat&amp;gt;) (&amp;lt;lon&amp;gt; &amp;lt;lat&amp;gt;) ...)
;;     ((&amp;lt;lon&amp;gt; &amp;lt;lat&amp;gt;) (&amp;lt;lon&amp;gt; &amp;lt;lat&amp;gt;) ...)
;;     ...
;;   )
;;   ("Surface2"
;;     ((&amp;lt;lon&amp;gt; &amp;lt;lat&amp;gt;) (&amp;lt;lon&amp;gt; &amp;lt;lat&amp;gt;) ...)
;;     ((&amp;lt;lon&amp;gt; &amp;lt;lat&amp;gt;) (&amp;lt;lon&amp;gt; &amp;lt;lat&amp;gt;) ...)
;;     ...
;;   )
;; )
(defun GetSurfBndyLatLonFromClosedDWG (filePath / ReleaseDBX doc cs)
  (defun ReleaseDBX ( / )
    (if doc (vlax-release-object doc))
  )
  ;; check exists
  (if (null (setq filePath (findfile filePath)))
    (progn (prompt (strcat "\nerror: bad filePath: " filePath)) (exit))
  );if
  ;; open dbx doc
  (setq doc (vlax-create-object (strcat "ObjectDBX.AxDbDocument." (substr (getvar 'acadver) 1 2))))
  (vla-open doc filePath)
  ;; ensure coordinate system for lat/longs
  (if (null (setq cs (GetCoordSys doc)))
    (progn
      (prompt (strcat "\nerror: no Coordinate System assigned within doc: " filePath))
      (ReleaseDBX)
      (exit)
    );progn
  );if
  ;; ensure surfaces exist
  (if (null (setq surfaces (GetSurfaces doc)))
    (progn
      (prompt (strcat "\nerror: no TIN surfaces within doc: " filePath))
      (ReleaseDBX)
      (exit)
    );progn
  );if
  (ReleaseDBX)
  ;; try to convert to lat/longs
  (if (and (ade_projsetsrc cs) (ade_projsetdest "LL84"))
    (progn
      (mapcar
       '(lambda (s / )
          (cons (car s)
            (mapcar
             '(lambda (b / )
                (mapcar 'ade_projptforward b)
              );lambda
              (cdr s)
            );mapcar
          );cons
        );lambda
        surfaces
      );mapcar
    );progn
  ;else
    (prompt (strcat "\nerror: current Coordinate System database does not contain: " cs))
  );if
);defun&lt;/LI-CODE&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;~DD&lt;/P&gt;</description>
      <pubDate>Fri, 21 Mar 2025 22:07:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/access-to-civil-3d-objects-via-object-dbx/m-p/13384335#M219</guid>
      <dc:creator>CodeDing</dc:creator>
      <dc:date>2025-03-21T22:07:59Z</dc:date>
    </item>
  </channel>
</rss>

