Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Auto-update layer states?

10 REPLIES 10
Reply
Message 1 of 11
bcsurvey
1864 Views, 10 Replies

Auto-update layer states?

I've only found posts for this topic on the Land Desktop and ACAD customization sections of this forum, and can't find anything useful in the Help section of C3D14 . . .

 

Is there a way to process .dwgs (either OOTB function or lisp) that will update layer states in viewports instead of having to go into each one and set an existing state?  When 1 viewport (which shares its layer state with several others) has its layer state changed, and those changes need to be made to the other viewports, it's cumbersome to have to go into each one and re-assign the layer state, especially when we're talking about a dozen or more drawings or even layout tabs in a single dwg.  For now, I'll only ask about multiple layout tabs in one drawing before inquiring into a way to update viewport layer states in multiple .dwgs.

 

Thank you

Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
10 REPLIES 10
Message 2 of 11
wfberry
in reply to: bcsurvey

Why not use the VPFreeze while in each viewport and forget about Layer State.  Just a thought.

 

Bill

 

 

Message 3 of 11
bcsurvey
in reply to: wfberry

Hi Bill,

What you've described is a very early step in the development of where all moderate to large projects usually wind up.  I do use the VPFreeze to bring the first viewport of what will be many to look the way I'd like.  But you know as well as I that, unless one has been doing the same type of work for many years, down the road as the project develops, new layers may need to be incorporated into the drawing.  Instead of having to see the layer states of other viewports (where new layers may or may not need to be visible) it would very useful to have the power to "assign" layer states to viewports such that when that state changes, these changes are also made in the respective viewports.  Otherwise, you're bouncing from dwg to dwg, layout to layout, viewport to viewport to assign the desired state.

Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
Message 4 of 11
Neilw_05
in reply to: bcsurvey

What you are describing has been a wish I have requested for a few years now. I would like to see the implementation of what I call Viewport styles. You would create a layer state, assign it a style and then apply it to viewports that you want to have a common layer state. Any changes to the style updates the viewports that have that style.

For now all we can do is step through and apply one by one.
Neil Wilson (a.k.a. neilw)
AEC Collection/C3D 2024, LDT 2004, Power Civil v8i SS1
WIN 10 64 PRO

http://www.sec-landmgt.com
Message 5 of 11
bcsurvey
in reply to: Neilw_05

I actually received this in response to a post I submitted this morning in the Land Desktop forum (it still exists!).  I'll have to get with some more saavy CAD users here to be sure I understand the use of matchline files, but it seems to be a feasible method, albeit not as user friendly as most CAD users would like:

 


cgentile wrote:

bc, we tailored this lisp to our needs and file structure, but the variables are pretty self explanatory. We use it in a script to run through a file directory which it opens the file, runs the lisp, saves, close, and continues on. We use ScriptWriter by Lee Mac to do this. The script saves us a large amount of time especially with large sets. Changing layer states is still a bit hard-coded; it can definitely be more user friendly...

 

The file structure we use in out office has each sheet as a separate file that references multiple "working" files. Through trial and error, we found the best way to manage layerstates is to have them saved in an external reference that will be in every plan drawing. For us, that is our matchline file which we use for matchlines, street labels, limit of work, etc. This eliminates the need to import or delete a layerstate into a sheet drawing file. This also makes sets more accessible for multiple users to modify the drawings. We are exploring (setvar "visretain" 0) to see if the external reference's layerstate is changed in its host file if those changes appear in the sheet file in which its layerstate is applied. 

 

Let you know of that development, but for now I hope this can get you started. 

 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::;;;
;;;;;;;; update layerstate for sheet drawings ;;;;;::;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::;;
(vl-load-com)
(defun c:uLS ( / nlsname olsname path dname vportlist vport)
(setq	pcli	"RHT";client folder
	pnum 	"RHTS401";project number
	pname	"RHTs401 #####" ;project name
	tb	"22x34";titleblock size file to match XXXs###_TB_##x##.dwg format
	);project path info

(setq 	pxref 	(strcat "P:\\" pcli "\\" pname "\\AutoCAD\\Xrefs\\")
	pacad 	(strcat "P:\\" pcli "\\" pname "\\AutoCAD\\")
	psheets (strcat "P:\\" pcli "\\" pname "\\AutoCAD\\Sheets\\")
	plstate	(strcat "P:\\" pcli "\\" pname "\\AutoCAD\\Sheets\\Layer States")
match (strcat pnum "_d_match.dwg") tb (strcat pnum "_tb_" tb ".dwg") dxr "*" );paths and filenames (setq lsname "0l_layout"
nlsname (strcat match lsname) ;new layer state NAME olsname (strcat match lsname) ;old layer state NAME ;; lsfname "0l_layout.las" ;.las FILENAME ;; suspended
) ;layerstates (command "vplayer" "m" "a" "*" "a" "") ;removes viewport overrides (layerstate-delete olsname) ;deletes old layerstate ;; (layerstate-import (strcat plstate lsfname)) ;imports .las file ;; suspended (if (/= (getvar "ctab") "model") (progn (setq vportlist (vl-sort (vports) '(lambda (v1 v2) (< (car v1) (car v2))))) ;lists viewports (if (> (length vportlist) 1) (progn (command "_mspace") ;activate vport (foreach vport (cdr vportlist) (setvar "cvport" (car vport)) (layerstate-restore nlsname (vlax-vla-object->ename (vla-get-activepviewport (vla-get-activedocument (vlax-get-acad-object))))) ;restore ) ;end foreach (command "pspace") ;deactivate vport ) ;end progn ) ;end if ) ;end progn ) ;end if (command "-purge" "a" "*" "n") (setvar "psltscale" 1) (servar "msltscale" 0) (setvar "dimscale" 1) (setvar "ltscale" 1)
(setvar "visretain" 0) );defun

 


Civil 3D 2019 (6.1)
Windows 10 Pro (21H2)
(i7-11850H @ 2.50 GHz)
32GB RAM
NVIDIA RTX A2000
Message 6 of 11
Neilw_05
in reply to: bcsurvey

I don't understand the programming but if you need to update numerous files it would be worthwhile to get it to work.

Be aware that it will update the format of every file so if you are working in a mixed environment it could be problematic.

If I understand his comment about experimenting with layer states in the host files with visretain=0, it won't work. The idea is to create a host file, load all the xrefs for a particular set of sheets into it and then xref that file into the sheets. By adjusting the layer state in the host file, all the sheets will reflect the layer state of the host file if they are set up with visretain=0. Unfortunately AutoCAD doesn't work that way. If visretain=0 in the sheet files, the sheets will reflect the layer states of the source files, not the host file.
Neil Wilson (a.k.a. neilw)
AEC Collection/C3D 2024, LDT 2004, Power Civil v8i SS1
WIN 10 64 PRO

http://www.sec-landmgt.com
Message 7 of 11
cgentile
in reply to: Neilw_05

neilw, after investigating the visretain, it did exactly the opposite of what I expected. It does seem you will have to restore an updated layerstate even if it's applied through an external reference. Having the parent of the layerstate be an external reference is, however, a better option than having to export it to a .las and importing it to each sheet files (in our case at least). You can use the lisp provided above to restore the external reference layerstate to an open drawing.

Using a script would be able to do this for multiple drawings without user input.
Message 8 of 11
Neilw_05
in reply to: cgentile

I'm not following what you are doing. Are you creating a host file and using that to control the layer display in the sheet files? If so how does that work?
Neil Wilson (a.k.a. neilw)
AEC Collection/C3D 2024, LDT 2004, Power Civil v8i SS1
WIN 10 64 PRO

http://www.sec-landmgt.com
Message 9 of 11
cgentile
in reply to: Neilw_05

I'll explain further: I'm using an external reference that stores the layerstate. This is referenced into another file that is being used solely for paperspace as a "sheet" file. The layerstate is then applied to the viewport within this file.

The lisp can be modified to remove the paths, etc. and just set the name of the layerstate to match the layerstate in the external reference. Essentially you wouldn't need to import the layerstate because it's already loaded being part of the external reference. The lisp would just restore this through a script that runs through multiple "sheet" files.
Message 10 of 11
Neilw_05
in reply to: cgentile

Got it. Thanks!
Neil Wilson (a.k.a. neilw)
AEC Collection/C3D 2024, LDT 2004, Power Civil v8i SS1
WIN 10 64 PRO

http://www.sec-landmgt.com
Message 11 of 11
AllenJessup
in reply to: bcsurvey

I don't know how to do exactly what you want. But in the mean time the VPLAYER command might help.

 

Allen



Allen Jessup
Engineering Specialist / CAD Manager

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report