Jump to content

LISP routine for a qleader to extract a name from block attribute


f700es

Recommended Posts

Hi all, I need a lisp routine to make a leader that will extract a model name of the block from it's attribute. I want it to work in paperspace so I have found this much out. So it will start with this..

 

;;turn the osnaps off, but remember the original setting
(setq myos (getvar "osmode"))
(setvar "osmode" 0)
(command "mspace")

and it will have to end with this ..

 

(command "pspace")
(setvar "osmode" myos)

The TAG in the block attribute is "PARTID". It's value is what I want the leader to display. I can send someone a block to look at if it will help.

 

TIA

 

Sean

Link to comment
Share on other sites

Extract the attributes with (vlax-invoke OBJ 'GetAttributes) and step through list. When you find the matching attribute, you can extract the desired data.

Link to comment
Share on other sites

I'd try something like this:

 

[b][color=BLACK]([/color][/b]defun c:seanatt [b][color=FUCHSIA]([/color][/b]/ ss en an ad av sp np[b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]or [b][color=MAROON]([/color][/b]not ss[b][color=MAROON])[/color][/b]
            [b][color=MAROON]([/color][/b]> [b][color=GREEN]([/color][/b]sslength ss[b][color=GREEN])[/color][/b] 1[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSelect INSERT To Attach"[/color][b][color=NAVY])[/color][/b]
        [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=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq en [b][color=NAVY]([/color][/b]ssname ss 0[b][color=NAVY])[/color][/b]
       an [b][color=NAVY]([/color][/b]entnext en[b][color=NAVY])[/color][/b]
       ad [b][color=NAVY]([/color][/b]entget an[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]/= [color=#2f4f4f]"SEQEND"[/color] [b][color=MAROON]([/color][/b]cdr [b][color=GREEN]([/color][/b]assoc 0 ad[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]if [b][color=MAROON]([/color][/b]= [color=#2f4f4f]"PARTID"[/color] [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 2 ad[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
            [b][color=MAROON]([/color][/b]setq av [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 1 ad[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]setq an [b][color=MAROON]([/color][/b]entnext an[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=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]or av [b][color=NAVY]([/color][/b]alert [color=#2f4f4f]"ATTRIB PARTID Not Found"[/color][b][color=NAVY])[/color][/b] [b][color=NAVY]([/color][/b]exit[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]initget 1[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq sp [b][color=NAVY]([/color][/b]list [b][color=MAROON]([/color][/b]getpoint [color=#2f4f4f]"\nLeader Start Point:   "[/color][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]setq np [b][color=MAROON]([/color][/b]getpoint [b][color=GREEN]([/color][/b]car sp[b][color=GREEN])[/color][/b] [color=#2f4f4f]"\nNext Point:   "[/color][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]grdraw [b][color=MAROON]([/color][/b]car sp[b][color=MAROON])[/color][/b] np 2 1[b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq sp [b][color=MAROON]([/color][/b]cons np sp[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

  [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.LEADER"[/color][b][color=FUCHSIA])[/color][/b]
  [b][color=FUCHSIA]([/color][/b]foreach p [b][color=NAVY]([/color][/b]reverse sp[b][color=NAVY])[/color][/b]
       [b][color=NAVY]([/color][/b]command p[b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
  [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]""[/color][b][color=FUCHSIA])[/color][/b]
  [b][color=FUCHSIA]([/color][/b]command av[b][color=FUCHSIA])[/color][/b]
  [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]> [b][color=MAROON]([/color][/b]getvar [color=#2f4f4f]"CMDACTIVE"[/color][b][color=MAROON])[/color][/b] 0[b][color=NAVY])[/color][/b]
         [b][color=NAVY]([/color][/b]command [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]


 

You'll need to add the MSPACE / PSPACE stuff at the appropriate times. My guess is the INSERT resides in MODEL SPACE, and that you want the LEADER in PAPER SPACE.

 

But it should be a start. -David

Link to comment
Share on other sites

Thanks Alan and you too David. David let me give yours a try and see how it works. Yes, the insert start in model and then ends in paper space.

Thanks

 

Sean

Link to comment
Share on other sites

  • 2 weeks later...

hello i want one help from u guys. Want to extract XYZ and roation angel of blocks is their any lisp 4 that. and one more thing i had one lisp in that i can extract only xyz plz help me

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...