pmxcad Posted February 25, 2012 Share Posted February 25, 2012 Hello. I made my first lisp. It`s a simple one and looks like script. It works ok (i have to copy and paste bij myself)but i want it to do automatic. Sure there is better way to do it, but it is a start. I want the lisp to do: -Select a attribute from a block (VIEWP, rectangle) -copie the value -starts the view command to create named view -W from window -Autocad asked for a name -Paste the attribute value -Enter -And selecting a window for the named-view..by me Done It looks simple but i don`t think it is. The copie and paste things are difficult for me. I used PAUSE for user input. It works, but it can be better. Thanks, PmxCAD NAMEDVW.dwg NAMEDVIEW.LSP Quote Link to comment Share on other sites More sharing options...
David Bethel Posted February 25, 2012 Share Posted February 25, 2012 (edited) Assuming: The tagname of the attribute is always "NAMEDVW" The ATTRIB string value is a valid symbol name Maybe something like this: [b][color=BLACK]([/color][/b]defun c:nvw [b][color=FUCHSIA]([/color][/b]/ ss en an ad nv p1 p2[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]0 . [color=#2f4f4f]"INSERT"[/color][b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]66 . 1[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] an [b][color=MAROON]([/color][/b]entnext en[b][color=MAROON])[/color][/b] ad [b][color=MAROON]([/color][/b]entget an[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]= [color=#2f4f4f]"ATTRIB"[/color] [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 0 ad[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]and [b][color=GREEN]([/color][/b]= [color=#2f4f4f]"NAMEDVW"[/color] [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 2 ad[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] [b][color=GREEN]([/color][/b]setq nv [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 1 ad[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq an [b][color=GREEN]([/color][/b]entnext an[b][color=GREEN])[/color][/b] ad [b][color=GREEN]([/color][/b]entget an[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]if nv [b][color=NAVY]([/color][/b]progn [b][color=MAROON]([/color][/b]initget 1[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq p1 [b][color=GREEN]([/color][/b]getpoint [b][color=BLUE]([/color][/b]strcat [color=#2f4f4f]"\nSelect 1 Corner Of "[/color] nv [color=#2f4f4f]" View Window: "[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]initget 1[b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]setq p2 [b][color=GREEN]([/color][/b]getcorner p1 [color=#2f4f4f]"\nSelect Opposite Corner Of View Window: "[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b] [b][color=MAROON]([/color][/b]command [color=#2f4f4f]"_.VIEW"[/color] [color=#2f4f4f]"_Window"[/color] nv p1 p2[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]alert [color=#2f4f4f]"No View Names Found"[/color][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1 nv[b][color=FUCHSIA])[/color][/b] [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b] -David Edited February 26, 2012 by David Bethel Change c: command name to avoid conflict in 2012 Quote Link to comment Share on other sites More sharing options...
pmxcad Posted February 25, 2012 Author Share Posted February 25, 2012 Thanks David. It is not working. Wel it does something, It opens the view dialog. What i like to have, Is running the lisp, select an attribute from a block, and after that, selecting/pick-points for the view..........done. The value/text from the selected attribute becomes the name of the named view. Thanks, PmxCAD Quote Link to comment Share on other sites More sharing options...
David Bethel Posted February 25, 2012 Share Posted February 25, 2012 It must be a setting in filedia or some dialog setting. It works on my systems R12 r13 2004 2012 -David Quote Link to comment Share on other sites More sharing options...
pBe Posted February 26, 2012 Share Posted February 26, 2012 Thanks David.It is not working. Wel it does something, It opens the view dialog. What i like to have, Is running the lisp, select an attribute from a block, and after that, selecting/pick-points for the view..........done. The value/text from the selected attribute becomes the name of the named view. Thanks, PmxCAD Works here as well (2009) I suggest you change the c:newview to something else like c:NW Quote Link to comment Share on other sites More sharing options...
David Bethel Posted February 26, 2012 Share Posted February 26, 2012 Works here as well (2009) I suggest you change the c:newview to something else like c:NW Looks like pBe is correct . NEWVIEW is a internal ACAD commend now. -David Quote Link to comment Share on other sites More sharing options...
pmxcad Posted February 26, 2012 Author Share Posted February 26, 2012 Yep.change it to nv.............works fine, thanks fooks. PmxCAD Quote Link to comment Share on other sites More sharing options...
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.