p01ak Posted April 20, 2009 Posted April 20, 2009 Hey I've been looking around for a while on the net. trying to find a way to switch to a selected Viewport in a layout tab and than run a Marco. BACKGROUND INFO: I have created a number of Marcos that I use to VPLAYER freeze and thaw layers and to colour specific layers a different colour. I have found this to be a very time effiencent way to Define Elec plans and Floor Covering plans. In addition i have made plot buttons so that it may select all the correct setting and plot the layout tab. e.g. "Elec Plan". I want to make the plot button that Defines the "Elec Plan" first before printing?? Any ideas? If i could have a code that allows me to 'Switch' to the Layout tab were the Viewport lives and then way to name a Viewport say "ELEC VP" OR/and a way of selecting it i think i would be have a chance, NOTE: For anyone that has had any experience with VPLAYER command, you need to have a Viewport Selected before being able to use any of the VPLAYER commands. any ideas or suggestions would be great. Quote
David Bethel Posted April 20, 2009 Posted April 20, 2009 DXF group 410 contains the layout name Group 69 is the viewport ID number So if you know that the ELEC VP viewport ID is 3 (ssget "X" (list (cons 0 "VIEWPORT")(cons 410 "ELEC VP")(cons 69 3))) Watch out though as the IDs are not saved in the drawing. They can change if another viewport has been deleted. I use a color scheme for viewports ( my electric is red ) So for me it is: (ssget "X" (list (cons 0 "VIEWPORT")(cons 410 "ELEC VP")(cons 62 1))) -David Quote
p01ak Posted April 20, 2009 Author Posted April 20, 2009 hey david, good to know it can be done, however i have no idea how to apply that, or where to find the viewport ID? any chance you could explain it alittle more indepth. thank Quote
David Bethel Posted April 20, 2009 Posted April 20, 2009 It looks like the ID is only attainable via an (entget) call. So I would recommend the color scenario. I'll write some code that could help. -David Quote
p01ak Posted April 20, 2009 Author Posted April 20, 2009 yeah that would be great. i must say that i have near no experience in lisp, but am more than willing to learn and work it out. this is a rough macro that i wrote up with the up to date knowledge that i have gained. I have worked out how to select and make a layout tab current in a simple Macro Enviroment. does anyone else or yourself know of a simple command to select a viewport for editting (have it highlighted in a heavy Boarder idicating that i am editting the model)? Code; FILEDIA 0 LAYOUT Set FP0 VPLAYER ..... ..VPCOLOUR & VPTHAW AND.. ..VPFREEZE MACRO..... .... ....... RESUME -PLOT Y FP0 Default Windows System Printer.pc3 etc.... RESUME MODEL RESUME FILEDIA 1 RESUME David, if you can write that code as a way to streamline any process it would be greatly appreciated. Thanks again Quote
David Bethel Posted April 20, 2009 Posted April 20, 2009 It would look like a little this: [b][color=BLACK]([/color][/b]defun c:vpauto [b][color=FUCHSIA]([/color][/b]/ vpl ln ss en[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]setq vpl '[b][color=NAVY]([/color][/b][b][color=MAROON]([/color][/b][color=#2f4f4f]"ELECTRIC"[/color] . 1[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][color=#2f4f4f]"GAS"[/color] . 7[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b][color=#2f4f4f]"PLUMBING"[/color] . 5[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not ln[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]not [b][color=GREEN]([/color][/b]snvalid ln[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]not [b][color=GREEN]([/color][/b]assoc ln vpl[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq ln [b][color=MAROON]([/color][/b]strcase [b][color=GREEN]([/color][/b]getstring [color=#2f4f4f]"\nCTAB Name: "[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"VIEWPORT"[/color][b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 410 ln[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]cons 62 [b][color=RED]([/color][/b]cdr [b][color=PURPLE]([/color][/b]assoc ln vpl[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]= [b][color=MAROON]([/color][/b]sslength ss[b][color=MAROON])[/color][/b] 1[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setq en [b][color=MAROON]([/color][/b]ssname ss 0[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]setvar [color=#2f4f4f]"CTAB"[/color] ln[b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]command [color=#2f4f4f]"_.VPLAYER"[/color] [color=#2f4f4f]"_Freeze"[/color] [color=#2f4f4f]"0"[/color] [color=#2f4f4f]"_S"[/color] en [color=#2f4f4f]""[/color] [color=#2f4f4f]""[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] It will need a lot of tweaking. VPL Format : CTAB_name . VIEWPORT_color -David Quote
p01ak Posted April 20, 2009 Author Posted April 20, 2009 ok so i worked out what ctab does, haha... now i just need to break the rest of the code down and work out what each part does, how generic could this code be?? from what i could gather from your first post it isnt very, i wondering if it will need constant tweaking if more viewports are added or removed. is there a way around this?? thanks for the code you provided, would you recommand any good lisp books, that explain each section of code? thanks again Quote
David Bethel Posted April 20, 2009 Posted April 20, 2009 how generic could this code be?? from what i could gather from your first post it isnt very, i wondering if it will need constant tweaking if more viewports are added or removed. is there a way around this?? Yes, constant tweaking would be needed. 1 work around would be if there is 1 and only 1 viewport per ctab. -David Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.