Author Topic: force network synch to update styles?  (Read 13871 times)

0 Members and 4 Guests are viewing this topic.

cadtag

  • Swamp Rat
  • Posts: 1101
force network synch to update styles?
« on: October 03, 2013, 08:57:08 PM »
If I change a structure in my stormwater drawing, and have already dref'ed that into a sheet - is there a way to force the synchronization to include the style from the master drawing?  Ex:  change a MH to a CB, or a CB to an MES in the master drawing, and the child drawing that has data-referenced in the pipe network is not updating the structure style to show the change.

Short of deleting and re-referencing (which would play hob with all the labels)
The only thing more dangerous to the liberty of a free people than big government is big business

Jeff_M

  • King Gator
  • Posts: 3945
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #1 on: October 03, 2013, 10:08:52 PM »
Nope. You can manually change the style in the Dref drawing but nothing that's automatic.

cadtag

  • Swamp Rat
  • Posts: 1101
Re: force network synch to update styles?
« Reply #2 on: October 04, 2013, 11:03:59 AM »
ragnsnaggle grumble*@#%,  I thought DRefs were supposed to _save_ time and keep all the dependent drawings coordinated.

sounds like a job for SincPac -- or does no one ever do that kind of structure swap? 
The only thing more dangerous to the liberty of a free people than big government is big business

Jeff_M

  • King Gator
  • Posts: 3945
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #3 on: October 04, 2013, 10:07:48 PM »
...... and keep all the dependent drawings coordinated.

sounds like a job for SincPac -- or does no one ever do that kind of structure swap? 
The issue stems from Autodesk thinks that it is a good idea to allow independent control of certain things in the dref'ed drawings so things can be shown differently. They semi-recently broke that philosophy, though, by changing how dref'ed pipe networks get synche'ed and apply the ObjectLayer settings. These now get reset to the drawing's settings every time a resync occurs. So no more placing existing pipes on a different layer, next time you open the drawing they will get moved back to the default layer.

So, IMHO, they should allow us to do what we want in the dref drawings, but should also allow us an easy way to update the structures & pipes if needed.

I will have a look at the API and see if this is something Sincpac might be able to address. Because yes, I have had occasion where I could've used this functionality.
« Last Edit: October 04, 2013, 10:17:35 PM by Jeff_M »

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #4 on: October 05, 2013, 01:56:47 PM »
This has frustrated me since first working with Civil 3D.

It's unfortunate that there is not a Civil 3D-specific equivalent version to VISRETAIN (C3DVISRETAIN?), where this drawing-saved system variable would control the style of DREF Object(s).

... It would also be nice for LandXML to be enhaced to support parent AECC* Object(s) Style definitions... Meaning that if one were to import from LandXML, the assigned Styles were able to be brought in at import, rather than being a separate procedure either before, or after-the-fact.

Cheers
"How we think determines what we do, and what we do determines what we get."

cadtag

  • Swamp Rat
  • Posts: 1101
Re: force network synch to update styles?
« Reply #5 on: October 07, 2013, 08:45:03 AM »
LandXML, being a vendor agnostic data transfer format, really doesn't have a place for a program -specific concept like C3D styles.    One could always propose that at LandXML.org - dunno how open they are to suggestions though but might be worth trying.  I o htink it would be an improvement if the PointGroups in LandXML included the group definition, rather than _just_ the list of point numbers in the group.

CDSTYLERETAIN -  That would be a handy variable  - although VISRETAIN is pretty heavy-handed.  Personally I'd prefer something that could do a more selective 'refresh from source', be it layer properties or styles. 
The only thing more dangerous to the liberty of a free people than big government is big business

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #6 on: October 07, 2013, 09:28:00 AM »
LandXML, being a vendor agnostic data transfer format, really doesn't have a place for a program -specific concept like C3D styles.    One could always propose that at LandXML.org - dunno how open they are to suggestions though but might be worth trying.  I o htink it would be an improvement if the PointGroups in LandXML included the group definition, rather than _just_ the list of point numbers in the group.

I didn't think about that... Perhaps a secondary file export (when LandXML export is done from C3D) of same LandXML file name, and different file extension (maintaining XML schema, like .APC?), which if found during LandXML import C3D would perform the style import?

Personally I'd prefer something that could do a more selective 'refresh from source', be it layer properties or styles.

I've never inspected what information is available from a given data reference before, but assuming that one can identify the parent drawing....

@Jeff - That could be incorporated easy enough via a ContextMenuExtension for the appropriate RXClass, no?



I usually use LISP to restore an XREF's layer properties via ObjectDBX in VISRETAIN == 1... I could easily see developing this for the AutoCAD side of things in .NET API, as I seem to be coding a lot of ContextMenuExtensions these days. Performing this via .NET side Database in lieu of ObjectDBX *should* be faster as well.

Cheers
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 3945
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #7 on: October 07, 2013, 10:19:21 AM »

@Jeff - That could be incorporated easy enough via a ContextMenuExtension for the appropriate RXClass, no?

Yes, I'm sure it could be. However, in my initial inspection I have found no method for obtaining the source drawing info from a Dref'ed object. I posted a question about this on the C3D customization forum. We'll see what Partha has to say.

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #8 on: October 07, 2013, 10:51:27 AM »

@Jeff - That could be incorporated easy enough via a ContextMenuExtension for the appropriate RXClass, no?

Yes, I'm sure it could be. However, in my initial inspection I have found no method for obtaining the source drawing info from a Dref'ed object. I posted a question about this on the C3D customization forum. We'll see what Partha has to say.

The parent drawing is specified within the respective DREF's XML 'shortcut'... Example from an Alignment (reformatted for clarity):

Code - XML: [Select]
  1. <?xml version="1.0"?>
  2. <!--PLEASE DO NOT EDIT THIS FILE!-->
  3. <ProjectInfo>
  4.         <ProjectDesc>
  5.         </ProjectDesc>
  6.         <Shortcuts>
  7.                 <Shortcut name="<FILEPATH>\<FILENAME>.dwg:<DREF NAME HERE>">
  8.                         <DwgRelPath path=".\<RELATIVEPATH>\<FILENAME>.dwg"/>
  9.                         <Criteria>
  10.                                 <File name="<FILEPATH>\<FILENAME>.dwg"/>
  11.                                 <Object
  12.                                         type="AeccDbAlignment"
  13.                                         useType="-1"
  14.                                         name="<DREF NAME HERE>"
  15.                                         useName="-1"
  16.                                         version="0"
  17.                                         useVersion="0"
  18.                                         handleLow="2786"
  19.                                         handleHigh="0"
  20.                                         useHandle="-1"
  21.                                         parentHandleHigh="0"
  22.                                         parentHandleLow="0"/>
  23.                                 <DisplayProperties
  24.                                         layer="0"
  25.                                         useLayer="0"
  26.                                         color="3"
  27.                                         useColor="0"
  28.                                         lineType="ByLayer"
  29.                                         useLineType="0"
  30.                                         lineWeight="-1"
  31.                                         useLineWeight="0"
  32.                                         <!--THIS IS WHERE C3D STYLE DEFINITION SHOULD BE SPECIFIED, AND IMPORTED FROM?-->
  33.                                         />
  34.                         </Criteria>
  35.                 </Shortcut>
  36.         </Shortcuts>
  37. </ProjectInfo>
  38.  



The problem being that each 'shortcut' XML file name includes its own GUID actually in the file name itself. One could simply iterate the ..\_Shortcuts\ folder looking for an XML File.Name.Contains(<DrefObjectName>), but I'd hope that Partha can identify a more direct means of accessing this aspect of the C3D API.

Cheers
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 3945
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #9 on: October 07, 2013, 12:03:29 PM »
....but I'd hope that Partha can identify a more direct means of accessing this aspect of the C3D API.

Cheers
Especially since the shortcut folder can be removed and, as long as the pathing remains the same, the Drefs will still work. The only time the XML file is needed is when creating the Dref or when the source object cannot be located. Furthermore, I can add a reference from 2 different shortcut paths into one drawing...not that this is a common occurrence, but it can, and does, get utilized. So now how do you know which Shortcuts folder to access?

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #10 on: October 07, 2013, 12:31:35 PM »
Especially since the shortcut folder can be removed and, as long as the pathing remains the same, the Drefs will still work. The only time the XML file is needed is when creating the Dref or when the source object cannot be located.

I only mentioned it as a possible (albeit imperfect) workaround, but am still hopeful for some sort of P/Invoke Method for being able to access the appropriate string directly.

Much the same as one can programmatically modify ..\ShortcutFolders.xml : /WorkingFolders/WorkingFolder XmlNodes' Current XmlAttribute, followed by a call to RefreshShortcutNode Command in order to change the working folder on the fly... Granted this example is not directly related, but is just an example of how one might utilize such a workaround (hack?) with the external XML if no direct API access exists.

... Now if only I could find a way of adding a ContextMenuExtension to the native Toolspace 'Data Shortcuts' node, or Layer Manager's Layer Items (for the pseudo-named 'Xref Layer Restore...' mentioned earlier, rather than attaching for RXClass == BlockReference, and being relegated to filtering for ObjectId.ObjectClass.Name == "AcDbBlockReference" & then BlockTableRecord.XrefStatus == XrefStatus.Resolved, etc.)

/OffTopic



Furthermore, I can add a reference from 2 different shortcut paths into one drawing...not that this is a common occurrence, but it can, and does, get utilized. So now how do you know which Shortcuts folder to access?

Interesting... Given the relative simplicity of our projects, I've never tried such a task, but I would presume that C3D precludes one from creating two DREFs of the same name, regardless of where the shortcut definition (XML) resides, no?

Cheers
"How we think determines what we do, and what we do determines what we get."

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: force network synch to update styles?
« Reply #11 on: February 27, 2015, 12:48:22 AM »
After much hair pulling, I decided to try and create a way to update dref pipe networks to match style and object layer of the parent pipe network. I couldn't figure out how to find the file where dref is targeting, so I just manually select the source file. Using ODBX, I can extract structure & pipe styles and layer (atm, it only deals with structures - testing simplicity), but when it iterates through the active drawing, where the dref network resides, it finds a matching part, but cannot apply a different style to the structure. I get nothing but "Error: Member not found".

I am curious, Jeff, if you made any progress with something of the sort.

I have a feeling legacy COM just has a bug that won't allow the user to change the structure style. I even made a simple command to do nothing but collect a list of structure styles in the active drawing and apply one of them to a selected structure.

I've attached all my code, for anyone that may be interested; the "test" command is my failed sync attempt and the "css" command is my testing function to choose a style from a list and apply it to a single selected structure (no error checking).

Code: [Select]
(defun c:test (/ *error* ss i objlst stylelst file odbx parts ass a b c)

  (defun *error* (msg)
    (and odbx (vlax-release-object odbx))
    (if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
      (progn (vl-bt) (princ (strcat "\nError: " msg)))
    )
  )



  (cond

    ;; check if a pipe network exists in drawing and is a reference
    ((progn
       (if (setq ss (ssget "_X" '((0 . "AECC_STRUCTURE"))))
(repeat (setq i (sslength ss))
   (setq o (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
   (if (eq (vlax-invoke o 'IsReferenceObject) 1) ; is dref part?
     (setq objlst (cons (cons (strcat (vla-get-name o) "_" (vlax-get o 'PartSizeName)) o)
objlst
  )
     )
   )
)
       )
       (not objlst)
     )
     (alert "No Data Referenced parts in active drawing.")
    )

    ;; get list of structure styles in active drawing
    ((progn
       (vlax-for x (vlax-get (AT:PipeDoc) 'StructureStyles)
(setq stylelst (cons (cons (vla-get-name x) x) stylelst))
       )
       (not stylelst)
     )
     (alert "No Part Styles in active drawing.")
    )

    ;; located master network dwg to sync files
    ((not (setq file (getfiled "Select drawing where master pipe network resides"
       (getvar 'DWGPREFIX)
       "dwg"
       2
     )
  )
     )
    )

    ;; odbx master file
    ((not
       (if (setq odbx (vlax-create-object
(if (< (setq release (atoi (getvar 'ACADVER))) 16)
  "ObjectDBX.AxDbDocument"
  (strcat "ObjectDBX.AxDbDocument." (itoa release))
)
      )
   )
(progn (vla-open odbx file) t)
       )
     )
     (alert "File could not be opened.")
    )

    ;; step through odbx drawing, find networks, extract style name
    ((progn
       (vlax-for x (vla-get-block (vla-get-layout (vla-get-modelspace odbx)))
(if (member (vla-get-objectname x) '("AeccDbStructure"))
   (setq parts (cons (cons (strcat (vla-get-name x) "_" (vlax-get x 'PartSizeName))
   (list (vla-get-name (vlax-get x 'Style))
(vla-get-layer x)
   )
     )
     parts
       )
   )
)
       )

       ;; (startapp "notepad" (AT:WriteToFile (vl-filename-mktemp nil nil "txt") parts t))

       (not parts)
     )
     (alert "No pipe networks in selected drawing.")
    )

    (t
     (foreach x objlst
       (if (setq ass (cdr (assoc (car x) parts)))
(progn
;;;    (setq a (cdr x)
;;; b (car ass)
;;; c (cdr (assoc (car ass) stylelst))
;;;    )
;;;    (startapp "notepad" (AT:WriteToFile (vl-filename-mktemp nil nil "txt") (list a b c) t))

   (vl-catch-all-apply 'vlax-put (list (cdr x) 'Style (cdr (assoc (car ass) stylelst))))
   (vl-catch-all-apply 'vla-put-layer (list (cdr x) (cadr ass)))
)
       )
     )
    )



  )

  (*error* nil)

  (princ)
)






(defun c:css (/ o stylelst style)

  (vlax-for x (vlax-get (AT:PipeDoc) 'StructureStyles)
    (setq stylelst (cons (cons (vla-get-name x) x) stylelst))
  )

  (if (and (setq o (car (entsel "\nSelect c3d structure: ")))
   (setq style (car (at:listselect "" "" 15 15 "false" (mapcar 'car stylelst))))
      )
    (vlax-put (vlax-ename->vla-object o) 'style (cdr (assoc style stylelst)))
  )

  (princ)
)



(defun AT:WriteToFile (file lst overwrite / fo)
  ;; Write list to file
  ;; file - file to write list to (must be in form "c:\\File.txt")
  ;; lst - list to write to file
  ;; overwrite - If T, will overwrite; nil to append
  ;; Alan J. Thompson, 04.28.09
  (if (and (vl-consp lst)
   (setq fo (open file
  (if overwrite
    "W"
    "A"
  )
    )
   )
      )
    (progn (foreach x lst (write-line (vl-princ-to-string x) fo))
   (close fo)
   file
    )
  )
)



(defun AT:ListSelect (title label height width multi lst / fn fo d item f)
  ;; List Select Dialog (Temp DCL list box selection, based on provided list)
  ;; title - list box title
  ;; label - label for list box
  ;; height - height of box
  ;; width - width of box
  ;; multi - selection method ["true": multiple, "false": single]
  ;; lst - list of strings to place in list box
  ;; Alan J. Thompson, 09.23.08 / 05.17.10 (rewrite)
  (setq fo (open (setq fn (vl-filename-mktemp "" "" ".dcl")) "w"))
  (foreach x (list (strcat "list_select : dialog { label = \"" title "\"; spacer;")
   (strcat ": list_box { label = \"" label "\";" "key = \"lst\";")
   (strcat "allow_accept = true; height = " (vl-princ-to-string height) ";")
   (strcat "width = " (vl-princ-to-string width) ";")
   (strcat "multiple_select = " multi "; } spacer; ok_cancel; }")
     )
    (write-line x fo)
  )
  (close fo)
  (new_dialog "list_select" (setq d (load_dialog fn)))
  (start_list "lst")
  (mapcar (function add_list) lst)
  (end_list)
  (setq item (set_tile "lst" "0"))
  (action_tile "lst" "(setq item $value)")
  (setq f (start_dialog))
  (unload_dialog d)
  (vl-file-delete fn)
  (if (= f 1)
    ((lambda (s / i s l)
       (while (setq i (vl-string-search " " s))
(setq l (cons (nth (atoi (substr s 1 i)) lst) l))
(setq s (substr s (+ 2 i)))
       )
       (reverse (cons (nth (atoi s) lst) l))
     )
      item
    )
  )
)


;   IsReferenceObject ()
;   IsReferenceStale ()
;   IsReferenceSubObject ()
;   IsReferenceValid


;;;  (vlax-for x (vla-get-block
;;;                  (vla-get-layout (vla-get-modelspace oDoc))
;;;                )



(defun AT:AeccDoc (/ i c)
  ;; Return and set (as global variable *AeccDoc*) Civil 3D Aecc Document object
  ;; (will also set global variables for acad object *Acad* and c3d aecc application *AeccApp*)
  ;; Alan J. Thompson, 2013.11.27, 2014.03.20
  (cond (*AeccDoc*)
((progn
   (setq i 2.9)
   (while (and (<= (setq i (+ i 0.1)) 50.) (not *AeccApp*))
     (if (not (vl-catch-all-error-p
(setq c (vl-catch-all-apply
  'vla-getinterfaceobject
  (list (cond (*Acad*)
      ((setq *Acad* (vlax-get-acad-object)))
)
(strcat "AeccXUiLand.AeccApplication." (vl-princ-to-string i))
  )
)
)
      )
)
       (setq *AeccApp* c)
     )
   )
   *AeccApp*
)
(setq *AeccDoc* (vlax-get *AeccApp* 'ActiveDocument))
)
  )
)


(defun AT:PipeDoc (/ i c)
  ;; Return and set (as global variable *PipeDoc*) Civil 3D Pipe Document object
  ;; (will also set global variables for acad object *Acad* and c3d pipe application *AeccApp*)
  ;; Alan J. Thompson, 2015.02.26
  (cond
    (*PipeDoc*)
    ((progn
       (setq i 2.9)
       (while (and (<= (setq i (+ i 0.1)) 50.) (not *PipeApp*))
(if (not (vl-catch-all-error-p
    (setq c (vl-catch-all-apply
      'vla-getinterfaceobject
      (list (cond (*Acad*)
  ((setq *Acad* (vlax-get-acad-object)))
    )
    (strcat "AeccXUiPipe.AeccPipeApplication." (vl-princ-to-string i))
      )
    )
    )
  )
     )
   (setq *PipeApp* c)
)
       )
       *PipeApp*
     )
     (setq *PipeDoc* (vlax-get *PipeApp* 'ActiveDocument))
    )
  )
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Jeff_M

  • King Gator
  • Posts: 3945
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #12 on: February 27, 2015, 09:47:52 AM »
Alan, not sure why the structure style cannot be set. I've tried a few different things with no success. BTW, I was getting an "unwind skipped on exception" error using your AT:PipeDoc function (I only tested the CSS command). I edited to be a bit more direct and then it allowed me to see it fail at the setting of the style:
Code - Auto/Visual Lisp: [Select]
  1. (defun AT:PipeDoc (/ i c C3D)
  2.   ;; Return and set (as global variable *PipeDoc*) Civil 3D Pipe Document object
  3.   ;; (will also set global variables for acad object *Acad* and c3d pipe application *PipeApp*)
  4.   ;; Alan J. Thompson, 2015.02.26
  5.   (cond
  6.     (*PipeDoc*)
  7.     ((and (setq *Acad* (vlax-get-acad-object))
  8.        (setq C3D (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key (vlax-user-product-key) (vlax-product-key) ) )
  9.       C3D (vl-registry-read C3D "Release")
  10.       C3D (substr C3D 1 (vl-string-search "." C3D (+ (vl-string-search "." C3D) 1) ) )
  11.       *PipeApp* (vla-getinterfaceobject *Acad* (strcat "AeccXUiPipe.AeccPipeApplication." C3D) )
  12.       )
  13.   )
  14.      (setq *PipeDoc* (vlax-get *PipeApp* 'ActiveDocument))
  15.     )
  16.   )
  17. )
  18.  

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #13 on: February 27, 2015, 11:05:10 AM »
I couldn't figure out how to find the file where dref is targeting, so I just manually select the source file.

Quite a bit more difficult with LISP than with .NET, but the files you're after are the same.

<RoamableRootPrefix> + "Project Management\\ShortcutFolders.xml will provide the WorkingFolder/ShortcutFolder XmlNode's path XmlAttribute's string value, which then allows you to locate <ShortcutFolderPathValue> + "\\_shortcuts\\<YourC3dObjectType>\\" in order to iterate the XML files contained within, and WCMATCH the XML file with the "<C3DObjectName>_<GUID>.xml" file naming convention.

At this point, you open the "<C3DObjectName>_<GUID>.xml" file, and obtain ProjectInfo/Shortcuts/Shortcut/DwgRelPath XmlNode's path XmlAttribute's value, or ProjectInfo/Shortcuts/Shortcut/Criteria/File XmlNode's name XmlAttribute's value for full file path.

HTH
"How we think determines what we do, and what we do determines what we get."

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: force network synch to update styles?
« Reply #14 on: February 27, 2015, 05:35:27 PM »
Alan, not sure why the structure style cannot be set. I've tried a few different things with no success. BTW, I was getting an "unwind skipped on exception" error using your AT:PipeDoc function (I only tested the CSS command). I edited to be a bit more direct and then it allowed me to see it fail at the setting of the style:
Code - Auto/Visual Lisp: [Select]
  1. (defun AT:PipeDoc (/ i c C3D).....
  2.  
Crap. I was hoping I was doing something wrong, or it was just my version of c3d. Thank you for a better way to retrieve the version info; that's pretty damn slick.

I couldn't figure out how to find the file where dref is targeting, so I just manually select the source file.

Quite a bit more difficult with LISP than with .NET, but the files you're after are the same.

<RoamableRootPrefix> + "Project Management\\ShortcutFolders.xml will provide the WorkingFolder/ShortcutFolder XmlNode's path XmlAttribute's string value, which then allows you to locate <ShortcutFolderPathValue> + "\\_shortcuts\\<YourC3dObjectType>\\" in order to iterate the XML files contained within, and WCMATCH the XML file with the "<C3DObjectName>_<GUID>.xml" file naming convention.

At this point, you open the "<C3DObjectName>_<GUID>.xml" file, and obtain ProjectInfo/Shortcuts/Shortcut/DwgRelPath XmlNode's path XmlAttribute's value, or ProjectInfo/Shortcuts/Shortcut/Criteria/File XmlNode's name XmlAttribute's value for full file path.

HTH
Pretty slick. I didn't realize that info was stored anywhere. Of course, without the ability to set the style, I've hit a brick wall. I've put learning to code in .net off for too long because I was "busy" or just being lazy, and now it's a real issue.
Can the structure/pipe style be successfully set in the .net api?
Time to start studying.
Thanks, guys.  :|
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #15 on: February 27, 2015, 11:34:11 PM »
I couldn't figure out how to find the file where dref is targeting, so I just manually select the source file.

Quite a bit more difficult with LISP than with .NET, but the files you're after are the same.

<RoamableRootPrefix> + "Project Management\\ShortcutFolders.xml will provide the WorkingFolder/ShortcutFolder XmlNode's path XmlAttribute's string value, which then allows you to locate <ShortcutFolderPathValue> + "\\_shortcuts\\<YourC3dObjectType>\\" in order to iterate the XML files contained within, and WCMATCH the XML file with the "<C3DObjectName>_<GUID>.xml" file naming convention.

At this point, you open the "<C3DObjectName>_<GUID>.xml" file, and obtain ProjectInfo/Shortcuts/Shortcut/DwgRelPath XmlNode's path XmlAttribute's value, or ProjectInfo/Shortcuts/Shortcut/Criteria/File XmlNode's name XmlAttribute's value for full file path.

HTH
Pretty slick. I didn't realize that info was stored anywhere. Of course, without the ability to set the style, I've hit a brick wall. I've put learning to code in .net off for too long because I was "busy" or just being lazy, and now it's a real issue.
Can the structure/pipe style be successfully set in the .net api?
Time to start studying.
Thanks, guys.  :|

Yeah, for an internal database, you'd think the host drawing would simply reference the parent drawing (but no). Haha

Not sure if .NET API can do that (yet), but just happen to know the best non-Autodesk Civil 3D developer there is - I'll see what he thinks - if it can, maybe we'll slap a LispFunction Method together? *not sure*

Cheers
"How we think determines what we do, and what we do determines what we get."

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: force network synch to update styles?
« Reply #16 on: February 28, 2015, 01:51:59 AM »
I couldn't figure out how to find the file where dref is targeting, so I just manually select the source file.

Quite a bit more difficult with LISP than with .NET, but the files you're after are the same.

<RoamableRootPrefix> + "Project Management\\ShortcutFolders.xml will provide the WorkingFolder/ShortcutFolder XmlNode's path XmlAttribute's string value, which then allows you to locate <ShortcutFolderPathValue> + "\\_shortcuts\\<YourC3dObjectType>\\" in order to iterate the XML files contained within, and WCMATCH the XML file with the "<C3DObjectName>_<GUID>.xml" file naming convention.

At this point, you open the "<C3DObjectName>_<GUID>.xml" file, and obtain ProjectInfo/Shortcuts/Shortcut/DwgRelPath XmlNode's path XmlAttribute's value, or ProjectInfo/Shortcuts/Shortcut/Criteria/File XmlNode's name XmlAttribute's value for full file path.

HTH
Pretty slick. I didn't realize that info was stored anywhere. Of course, without the ability to set the style, I've hit a brick wall. I've put learning to code in .net off for too long because I was "busy" or just being lazy, and now it's a real issue.
Can the structure/pipe style be successfully set in the .net api?
Time to start studying.
Thanks, guys.  :|

Yeah, for an internal database, you'd think the host drawing would simply reference the parent drawing (but no). Haha

Not sure if .NET API can do that (yet), but just happen to know the best non-Autodesk Civil 3D developer there is - I'll see what he thinks - if it can, maybe we'll slap a LispFunction Method together? *not sure*

Cheers
Hell, I wish you could click on a surface, etc. dref and it would tell you where it's referencing.

Man, I would be forever appreciative, if it works and you have the time. If it isn't available in dotNET, does that mean it could be possible with C+? I know I read somewhere about certain properties weren't available in the NET api, but could be accomplished using COM. The ability to set it with COM is there, it just doesn't seem to work when accessing it via LISP.
This would solve my issue with pipe networks not updating dref styles, and breaking a part's connection to the list if you edit an optional property at the object level. The rest of the code I posted works w/o issue, I just can't get it to set the damn structure style.

This has been the wake up call I've needed and I'll be spending the weekend digging into dotNET. Starting advice?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #17 on: February 28, 2015, 03:28:54 AM »
To clarify, much of what we can do in .NET API, particularly in terms of Civil 3D, still uses COM (which may make no sense).

Similar to LISP, not everything about C3D APIs is exposed to even .NET, or ObjectARX - COM only.

However, .NET API has the ability to use 'pure' .NET (to open those version specific XML files as XmlDocument, and iterate the XmlNodes, reading the corresponding XmlAttribute values, etc), and COM (to access the AECC Objects Style, etc) in concert, using early/late binding in earlier .NET Frameworks, or dynamics as an advent in newer Frameworks.

In any event, you know we'll all pitch in where we can.

Kerry started a good thread here on how to get started with .NET API (linked below), and I've previously helped others with similar requests here and here:

http://www.cadtutor.net/forum/showthread.php?90945-Which-program-to-work-with-VB.net

http://www.cadtutor.net/forum/showthread.php?90713-Can-AutoCAD-2015-be-used-with-Visual-Studio-2015&p=622866&viewfull=1#post622866

Quote from: BlackBox
Also, these may be of use:

http://forums.autodesk.com/t5/net/autocad-2015-net-wizard/m-p/5169991#M41454

http://www.theswamp.org/index.php?topic=47450.0



« Last Edit: February 28, 2015, 03:34:22 AM by BlackBox »
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 3945
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #18 on: February 28, 2015, 12:21:54 PM »

Can the structure/pipe style be successfully set in the .net api?

This has been the wake up call I've needed and I'll be spending the weekend digging into dotNET. Starting advice?
Yes, the structure style can be changed in .NET, Here's a very quick sample that demonstrates how:
Code - C#: [Select]
  1.         [CommandMethod("ChangeStructStyle")]
  2.         public void changestructstyle()
  3.         {
  4.             Document doc = Application.DocumentManager.MdiActiveDocument;
  5.             Editor ed = doc.Editor;
  6.             PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect a structure:");
  7.             entOpts.AllowNone = true;
  8.             entOpts.SetRejectMessage("...not a Civil3D structure.");
  9.             entOpts.AddAllowedClass(typeof(Structure), true);
  10.             PromptEntityResult entRes = ed.GetEntity(entOpts);
  11.             if (entRes.Status != PromptStatus.OK)
  12.                 return;
  13.             using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
  14.             {
  15.                 Structure structure = (Structure)entRes.ObjectId.GetObject(OpenMode.ForWrite);
  16.                 ObjectId styleId = CivilApplication.ActiveDocument.Styles.StructureStyles["Basic"];
  17.                 structure.StyleId = styleId;
  18.                 tr.Commit();
  19.             }
  20.         }
  21.  

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #19 on: February 28, 2015, 05:14:06 PM »

Can the structure/pipe style be successfully set in the .net api?

This has been the wake up call I've needed and I'll be spending the weekend digging into dotNET. Starting advice?
Yes, the structure style can be changed in .NET, Here's a very quick sample that demonstrates how:
Code - C#: [Select]
  1.         [CommandMethod("ChangeStructStyle")]
  2.         public void changestructstyle()
  3.         {
  4.             Document doc = Application.DocumentManager.MdiActiveDocument;
  5.             Editor ed = doc.Editor;
  6.             PromptEntityOptions entOpts = new PromptEntityOptions("\nSelect a structure:");
  7.             entOpts.AllowNone = true;
  8.             entOpts.SetRejectMessage("...not a Civil3D structure.");
  9.             entOpts.AddAllowedClass(typeof(Structure), true);
  10.             PromptEntityResult entRes = ed.GetEntity(entOpts);
  11.             if (entRes.Status != PromptStatus.OK)
  12.                 return;
  13.             using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
  14.             {
  15.                 Structure structure = (Structure)entRes.ObjectId.GetObject(OpenMode.ForWrite);
  16.                 ObjectId styleId = CivilApplication.ActiveDocument.Styles.StructureStyles["Basic"];
  17.                 structure.StyleId = styleId;
  18.                 tr.Commit();
  19.             }
  20.         }
  21.  

Thanks for the prompt confirmation, Jeff.

Now, that leaves only the simple task of iteratively 'getting' the parent Style for each Structure, and Pipe selected from host drawing using the XmlDocuments I mention above (overwriting said Styles as needed), no?

Not sure if this can be done via ReadDwgFile() side-database, or perhaps even via Core Console in parallel (particularly if there is more than one parent drawing for the selected Structures and/or Pipes?)... Further, less 'expensive' to clone parent Style(s) to MdiActiveDocument's Database, or WBLOCK those out into ..\temp\ drawing(s), and simply insert? Side-database I presume.

Cheers
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 3945
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #20 on: February 28, 2015, 06:17:22 PM »

Now, that leaves only the simple task of iteratively 'getting' the parent Style for each Structure, and Pipe selected from host drawing using the XmlDocuments I mention above (overwriting said Styles as needed), no?

Not sure if this can be done via ReadDwgFile() side-database Yes, this is quite doable., or perhaps even via Core Console in parallel (particularly if there is more than one parent drawing for the selected Structures and/or Pipes?) Not sure about this. I don't think CivilApplication is available in the CoreConsole, but have never looked into it.... Further, less 'expensive' to clone parent Style(s) to MdiActiveDocument's Database It's very simple to get the style, verify whether it exists in the current dwg, and copy if not, or WBLOCK those out into ..\temp\ drawing(s), and simply insert? Side-database I presume.

Cheers

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #21 on: February 28, 2015, 08:33:17 PM »
Sounds like we've got the makings of a simple ContextMenuExtension and/or CommandMethod regardless.

As for CC, as I understand it, the Civil* Objects don't need to be exposed per-se, as CC can NETLOAD assemblies (which would do the grunt work presumably). *not sure*

In any event, sounds like ReadDwgFile() is the way to go here.

I already have some code for obtaining the parent drawing as described above, which I'll post the next time I'm at the office/RDP.

Cheers
"How we think determines what we do, and what we do determines what we get."

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: force network synch to update styles?
« Reply #22 on: March 02, 2015, 08:23:33 AM »
I found the "export to" function for styles. Does that not work? How do you wblock out a style when you have to have a reference object to create a style object to wblock out, or can you wblock portions of the database?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Jeff_M

  • King Gator
  • Posts: 3945
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #23 on: March 02, 2015, 08:48:28 AM »
Alan, forget Wblock, the ExportTo works fine.

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #24 on: March 02, 2015, 02:29:05 PM »
Alan, forget Wblock, the ExportTo works fine.

This.
"How we think determines what we do, and what we do determines what we get."

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: force network synch to update styles?
« Reply #25 on: March 02, 2015, 04:00:29 PM »
Alan, forget Wblock, the ExportTo works fine.
Right on. Just going on the previous post. Not like I have any use for this information just yet.  The joys of learning a new language.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #26 on: March 02, 2015, 04:11:15 PM »
... The joys of learning a new language.

Which language did you decide to learn (i.e., C#, VB, etc.)? :-)

[Edit] - Also, here's an example of ExportTo() Method, that discusses the importance of StyleConflictResolverType.



... Say C#, say C#, say C#
« Last Edit: March 02, 2015, 04:14:34 PM by BlackBox »
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 3945
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #27 on: March 02, 2015, 05:12:58 PM »

Which language did you decide to learn (i.e., C#)? :-)

....the importance of StyleConflictResolverType.

And the just as important knowledge that the StyleConflictResolverType doesn't always work as expected....

alanjt

  • Needs a day job
  • Posts: 5327
  • Standby for witty remark...
Re: force network synch to update styles?
« Reply #28 on: March 02, 2015, 07:58:27 PM »
... The joys of learning a new language.

Which language did you decide to learn (i.e., C#, VB, etc.)? :-)

[Edit] - Also, here's an example of ExportTo() Method, that discusses the importance of StyleConflictResolverType.



... Say C#, say C#, say C#
C# seemed the choice over vb, and you just confirmed it. :)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #29 on: March 03, 2015, 01:51:46 AM »

Which language did you decide to learn (i.e., C#)? :-)

....the importance of StyleConflictResolverType.

And the just as important knowledge that the StyleConflictResolverType doesn't always work as expected....

Yikes - what do you do then, second attempt, or iterate the source/target style's settings?
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #30 on: March 03, 2015, 01:52:33 AM »
... The joys of learning a new language.

Which language did you decide to learn (i.e., C#, VB, etc.)? :-)

[Edit] - Also, here's an example of ExportTo() Method, that discusses the importance of StyleConflictResolverType.



... Say C#, say C#, say C#
C# seemed the choice over vb, and you just confirmed it. :)

... Always happy to not help.  :-D
"How we think determines what we do, and what we do determines what we get."

Jeff_M

  • King Gator
  • Posts: 3945
  • C3D user & customizer
Re: force network synch to update styles?
« Reply #31 on: March 03, 2015, 09:38:06 AM »
There are a few Textstyles that do not update as expected. The one that was brought to my attention is ProfileViewStyle's text components do not get Overwritten when specified to do so. There may be others, but I have not checked and I have not had any other reports from users.

BlackBox

  • King Gator
  • Posts: 3745
Re: force network synch to update styles?
« Reply #32 on: December 23, 2015, 11:01:04 AM »
Revisiting an old thread....



Alan - Did you ever get to upgrade to 2015?

http://forums.augi.com/showthread.php?164863-pipe-styles-keep-changing&p=1306296&viewfull=1#post1306296

Cheers
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3745
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3745
"How we think determines what we do, and what we do determines what we get."