...... and keep all the dependent drawings coordinated.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.
sounds like a job for SincPac -- or does no one ever do that kind of structure swap?
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.
Personally I'd prefer something that could do a more selective 'refresh from source', be it layer properties or styles.
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.
@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.
@Jeff - That could be incorporated easy enough via a ContextMenuExtension for the appropriate RXClass, no?
....but I'd hope that Partha can identify a more direct means of accessing this aspect of the C3D API.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?
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?
(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))
)
)
)
I couldn't figure out how to find the file where dref is targeting, so I just manually select the source file.
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: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.Code - Auto/Visual Lisp: [Select]
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.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.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
Can the structure/pipe style be successfully set in the .net api?
Time to start studying.
Thanks, guys. :|
Hell, I wish you could click on a surface, etc. dref and it would tell you where it's referencing.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.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
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
Also, these may be of use:
http://forums.autodesk.com/t5/net/autocad-2015-net-wizard/m-p/5169991#M41454 (http://forums.autodesk.com/t5/net/autocad-2015-net-wizard/m-p/5169991#M41454)
http://www.theswamp.org/index.php?topic=47450.0 (http://www.theswamp.org/index.php?topic=47450.0)
Yes, the structure style can be changed in .NET, Here's a very quick sample that demonstrates how:
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:
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?Code - C#: [Select]
[CommandMethod("ChangeStructStyle")] public void changestructstyle() { Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed = doc.Editor; entOpts.AllowNone = true; entOpts.SetRejectMessage("...not a Civil3D structure."); PromptEntityResult entRes = ed.GetEntity(entOpts); if (entRes.Status != PromptStatus.OK) return; using (Transaction tr = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()) { Structure structure = (Structure)entRes.ObjectId.GetObject(OpenMode.ForWrite); ObjectId styleId = CivilApplication.ActiveDocument.Styles.StructureStyles["Basic"]; structure.StyleId = styleId; tr.Commit(); } }
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
Alan, forget Wblock, the ExportTo works fine.
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.
... The joys of learning a new language.
And the just as important knowledge that the StyleConflictResolverType doesn't always work as expected....
Which language did you decide to learn (i.e., C#)? :-)
....the importance of StyleConflictResolverType.
C# seemed the choice over vb, and you just confirmed it. :)... The joys of learning a new language.
Which language did you decide to learn (i.e., C#, VB, etc.)? :-)
[Edit] - Also, here (http://adndevblog.typepad.com/infrastructure/2013/02/resolving-style-conflicts-in-exporting-styles-using-net-api.html)'s an example of ExportTo() Method, that discusses the importance of StyleConflictResolverType.
... Say C#, say C#, say C#
And the just as important knowledge that the StyleConflictResolverType doesn't always work as expected....
Which language did you decide to learn (i.e., C#)? :-)
....the importance of StyleConflictResolverType.
C# seemed the choice over vb, and you just confirmed it. :)... The joys of learning a new language.
Which language did you decide to learn (i.e., C#, VB, etc.)? :-)
[Edit] - Also, here (http://adndevblog.typepad.com/infrastructure/2013/02/resolving-style-conflicts-in-exporting-styles-using-net-api.html)'s an example of ExportTo() Method, that discusses the importance of StyleConflictResolverType.
... Say C#, say C#, say C#
Oh it's happening....
(http://forums.augi.com/attachment.php?attachmentid=107021&d=1545426845)