View Full Version : Freezing preset layers in a viewport
cadd4la
2022-04-22, 09:53 PM
Hello everyone,
I'm in need of a lisp program that after I select the viewport it pops up a list of preset names i.e. sht1, sht2, sht3, etc. then after I select from the list it will do a viewport freeze of all the other layers that have -sht* at the end and does not match what I selected, the layers will be *-sht2, *-sht3, *-sht4, etc. at the end of the layer names and keep all the layers that I selected from the list on. Therefore, I don't have to have multiple lisp programs to keep that one layer on and turn off all the other layers in a different viewport in the file that I don't want those layers to show.
Typical layer names
LP-PLNT_TREE-SHT1
LP-PLNT_TREE-SHT2
LP-PLNT_VINE-SHT1
LP-PLNT_VINE-SHT2
Thanks, for the help.
BlackBox
2022-04-25, 03:55 PM
Why not use the OOTB functionality?
Consider a combination of sheet templates & layer states.
cadd4la
2022-04-27, 11:32 PM
Blackbox,
I'm not always going to have that many layer names for my project, I may only have sht1 and sht2 in one project, in another project I may have sht1 through sht3, and in another, I may have sht1 through sht9.
Cadd4la
Have you attempted any code for this or are you just asking for someone to code this up for you?
How would one request the # for a *SHT# layer name?
(setq intSuffix (getint "\nSpecify sheet number: "))
This would get an integer of that number. This would provide no error checking of course, but it would require an integer be provided.
If you want to just make it a string, you might try this:
(setq strSuffix (getstr "\nSpecify sheet number: "))
If you went with the integer from the beginning, you would need to convert it to a string before concatenating it all together for future use.
(setq strSuffix (itoa intSuffix))
You could then concatenate this into the requested layer suffix like so...
(setq strLayerSuffix (strcat "*SHT" strSuffix))
Once you have that, you would need to run the VPLAYER command to make the layer changes you want to accomplish.
(command "VPLAYER" "Freeze" "*SHT*" "Current" "Thaw" strLayerSuffix "Current" "")
Most of that can get you started on compiling a routine for your request. There are other steps to meet your request. A search of the AutoLISP forum should find other small steps to get you there. Unfortunately, I can't volunteer that much time to build a one-off solution for something I have no need for.
Tom Beauford
2022-04-28, 01:52 PM
Hello everyone,
I'm in need of a lisp program that after I select the viewport it pops up a list of preset names i.e. sht1, sht2, sht3, etc. then after I select from the list it will do a viewport freeze of all the other layers that have -sht* at the end and does not match what I selected, the layers will be *-sht2, *-sht3, *-sht4, etc. at the end of the layer names and keep all the layers that I selected from the list on. Therefore, I don't have to have multiple lisp programs to keep that one layer on and turn off all the other layers in a different viewport in the file that I don't want those layers to show.
Typical layer names
LP-PLNT_TREE-SHT1
LP-PLNT_TREE-SHT2
LP-PLNT_VINE-SHT1
LP-PLNT_VINE-SHT2
Thanks, for the help.
Curious why have layers with *-sht2, *-sht3, *-sht4, etc. added at the end of their layer names when controlling layer properties is so easy?
I haven't seen anything like that since multiple layouts were introduced 23 versions ago.
Like BLACKBOX I believe taking advantage of OOTB functionality would make your workflow a lot easier and help you sleep better at night.
cadd4la
2022-04-29, 12:32 AM
Opie,
This is beyond my coding ability so I'm looking to have someone code it for me.
Thanks,
cadd4la
2022-04-29, 01:05 AM
Curious why have layers with *-sht2, *-sht3, *-sht4, etc. added at the end of their layer names when controlling layer properties is so easy?
I haven't seen anything like that since multiple layouts were introduced 23 versions ago.
Like BLACKBOX I believe taking advantage of OOTB functionality would make your workflow a lot easier and help you sleep better at night.
Tom,
Can you please tell me how to do this by using layer properties?
This is what I'm doing now. I draw my planting plan with trees, shrubs, vines, etc for the project in model space then in layout, I have different tabs for the different areas of the project with match lines and one viewport per tab. I need to make sure that only the plant material that are within the match line area is the only thing showing in the viewport to make sure it doesn't get double-counted by the contractor. so if I have two areas I will make layers named LP-PLNT_TREE-SHT1 & LP-PLNT_TREE-SHT2, LP-PLNT_VINE-SHT1 & LP-PLNT_VINE-SHT2, and two layout tabs. In sht one layout tab I will go into floating model space, open the layer manager, do a layer search for *sht2 to filter all the layers for sht 2, do a viewport freeze on all of them, and get out of the viewport.
I'm looking to eliminate those 5 steps so all I have to do is run the code, select from the given sheet list for the layer ending with the given name (i.e. sht1) I don't want to have a viewport freeze done but all the others that have sht2, sht3, etc will be frozen, and then select the viewport (3 steps)
I hope this helps explain why I need this program.
Cadd4la
Tom Beauford
2022-04-29, 03:42 PM
Tom,
Can you please tell me how to do this by using layer properties?
This is what I'm doing now. I draw my planting plan with trees, shrubs, vines, etc for the project in model space then in layout, I have different tabs for the different areas of the project with match lines and one viewport per tab. I need to make sure that only the plant material that are within the match line area is the only thing showing in the viewport to make sure it doesn't get double-counted by the contractor. so if I have two areas I will make layers named LP-PLNT_TREE-SHT1 & LP-PLNT_TREE-SHT2, LP-PLNT_VINE-SHT1 & LP-PLNT_VINE-SHT2, and two layout tabs. In sheet one layout tab I will go into floating model space, open the layer manager, do a layer search for *sht2 to filter all the layers for sht 2, do a viewport freeze on all of them, and get out of the viewport.
I'm looking to eliminate those 5 steps so all I have to do is run the code, select from the given sheet list for the layer ending with the given name (i.e. sht1) I don't want to have a viewport freeze done but all the others that have sht2, sht3, etc will be frozen, and then select the viewport (3 steps)
I hope this helps explain why I need this program.
Cadd4la
We receive projects with planting plans on multiple sheets all the time and I've never seen them done with layers like that.
When there's a lot of them Tables are often used and if match lines aren't clear enough to make sure they're not double-counted by the contractor why not just draw a polyline around the plants matchline to matchline then use -VPORTS Object to select the polyline to clip the viewport to show only the ones you want on that sheet?
Personally I think matchlines work best as when the contractor goes to the next sheet it's easier to see how to continue the planting he did on the previous sheet.
In Civil 3D areas beyond the matchlines can be shaded as well.
BlackBox
2022-04-29, 05:24 PM
Just to clarify my earlier suggestion:
If you happen to create a template setup that includes all of your layers, for the most number of sheets you could possibly ever have (1+ for CYA), then simply manually apply your VP freeze in each (or Layer State?)... initially adjust Viewport view locations about the project, then you'd just need to do the work, and it all shows up (or doesn't) the way you're after, every time.
Delete layouts you don't need when you start a project and need to add a sheet when project scope changes? Import the layout from your template, which already has the required Viewport Layer settings saved.
Custom code is great - I very much enjoy thinking\writing\testing\breaking, even dreaming in it (sometimes, don't judge me) Haha - it should always be about the right tool for the right job.
But custom code to do what you've described, simply is not the best use of your or our time & effort, when there's already an OOTB way to do all of this for you, from the outset, with minimal effort on your part.
Now, if you're stubborn (like me), and determined to be able to do this with custom code - you start coding it - yes, you go read what you need to read and teach yourself to code (like me, with the help of many others), then post your code when you get stuck, and I (and others) will help you overcome each hurdle along the way.
Just know that when you do finally put in all that time & effort to earn the proficiency needed to code such a thing yourself - you'll both be better for it in the long run, and you'll see that what we've suggested here really was more efficient & productive.
Choice is yours. :beer:
Cheers
Bruno.Valsecchi
2022-05-03, 10:38 AM
Hi,
Try this, you can select One or more extension with Control+Pick or UpperCase+Pick in dialog box
cadd4la
2022-05-09, 05:14 AM
Bruno,
It works great. I'm so grateful that people like you are on here, it reminds me of when I first joined some twenty years and you asked for someone to write a code to help you out and you would two, maybe three different visions, and the people would learn from each other on the different ways you can write code to do the same thing. Nowadays it seems you have to give people justification on why they should help write code to help you.
Thank you so much.
Cadd4la
Bruno,
..Nowadays it seems you have to give people justification on why they should help write code to help you.
Thank you so much.
Cadd4la
I'm glad that worked out for you.
Regarding your last statement, yes I've seen it here and in other forums such as The Swamp.
I think it's because some people, usually new members, post a thread asking for a routine to be written for them, instead of doing some research or giving it a try first.
I think the resistance is because members work for a living and are providing a service, and are willing to help those who help themselves, not just asking, sometimes demanding a code to be written for them.
I am an "intermediate lisper" at best, so I too sometimes need help with stuff outside my knowledge level, I get more help when I post where I'm at, or links to what I found.
I also am willing to help (if I even can) with members who seem to have put in some effort.
I have only seen resistance in those situations, not where someone has put in effort or has helped out in other ways.
That is what I've seen anyway.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.