Jump to content

get data from attribute needs help


pmxcad

Recommended Posts

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

Link to comment
Share on other sites

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 by David Bethel
Change c: command name to avoid conflict in 2012
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...