Author Topic: XREF stamp Deluxe Edition ?  (Read 5181 times)

0 Members and 1 Guest are viewing this topic.

phoulx

  • Guest
XREF stamp Deluxe Edition ?
« on: January 24, 2006, 11:11:14 AM »
Me: Very basic LISP & Diesel skills, no VBA or others.  ACAD 2004 & LT.  Wondering if I've bitten off more than I can chew.

My Mission:  A way to list xrefs in a drawing with their respective path, name and saved on dates/times.  This info would then be inserted onto the drawing for a visual record of what version of each xref is used on the sheet.  The saved on dates/times would have to update somehow as the xrefs are updated. 

I'm picturing the user selecting one xref at a time; routine gathers xref path, xref name and saved on date; this info ghosting on screen allowing user to select the best insertion point; placing the text. The text would be set to its own layer which could be a plotting or non-plotting layer depending on the circumstances. The xref saved dates could then be updated either by running the routine or possibly just upon opening the drawing.

This could be used to show the dates of any client backgrounds used in a drawing so when the arguments start, we'll be able to see exactly what version of their files were supplied to us.  Keeping this in mind, I don't want to open their dwgs to insert a block or rtext and then save it altering the true saved on date.  Another use could be, a company standards sheet with several of our typical details, notes etc. xrefed into it.  When this standard drawing is opened, the user can see that a certain detail was updated recently vs the two-year-old copy sitting on his desk.

Suggestions?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: XREF stamp Deluxe Edition ?
« Reply #1 on: January 24, 2006, 11:21:39 AM »
Shouldn't be too hard to do.  The only hard part is the auto-update, you would have to use a reactor.  If you don't want to go that route, then maybe you can have the user either select an existing text to overwrite, or place it on the drawing.  You won't be able to use this for LT (as you can't use lisp).  I don't know diesel, so I'm not sure about that.
Psuedo code.
Use entsel to select the xref.
Use tblobjname with block and the name of the xref
Use findfile once you get the path listed for the xref
Use vl-file-systime to check the date of the xref drawing
Prompt the user to select existing text, or place new text on the drawing.

You may want to create a new layer for the xref text, and then when the program is ran, it can check for any xref (ssget), and then once it gets those, it will search your drawing for that one layer, and erase all the text, or rewrite the text.

Hope that gets you started in the right direction.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

phoulx

  • Guest
Re: XREF stamp Deluxe Edition ?
« Reply #2 on: January 24, 2006, 11:46:38 AM »
It seems a reactor would be the way to go then.  To me, the auto-update is key.  We have users with varied experience and I don't want to add more steps to be forgotten/ignored.  I thought the diesel/rtext was going to help but no dice.  Yes, it auto-updated a list of xrefs on the dwg.  No, it did not include saved on date or work on LT.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: XREF stamp Deluxe Edition ?
« Reply #3 on: January 24, 2006, 11:57:23 AM »
You don't have to go the reactor route, just have two different commands.  One will run on opening the drawing, and the other will work from the command line.  Even experienced writer don't know all there is to know about reactors.  There are some here that know, I'm not one.

How about you start, and then post back when you get stuck.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: XREF stamp Deluxe Edition ?
« Reply #4 on: January 24, 2006, 02:22:31 PM »
Are you stuck somewhere?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

phoulx

  • Guest
Re: XREF stamp Deluxe Edition ?
« Reply #5 on: January 25, 2006, 01:03:17 PM »
Yeah, stuck with "real" work now which is why I'm here at lunch.  Actually I plan on getting stuck at tblobjname- haven't used that one before.

phoulx

  • Guest
Re: XREF stamp Deluxe Edition ?
« Reply #6 on: January 25, 2006, 02:04:59 PM »
All I had time for today and it gave me: The following error has occured, bad argument type: stringp (<Entity name:
7ef89a28> (202.097 14.9909 0.0)) so I'm guessing I did something studid.

(defun c:xxrr (/ clay omd xrpk pta xrn xreg)
    (setq clay (getvar "clayer"))
    (command "-layer" "m" "xrefinfo" "c" "4" "" "")
    (setq omd (getvar "orthomode"))
    (setvar "orthomode" 1)
  (setq xrpk (entsel "\nSelect Xref: "))
    (setq xrn (tblobjname "block" xrpk))
    (setq xreg (entget xrn))
  (setq pta (getpoint "\nSelect location for xrefinfo: "))
      (command "text" pta 0 xreg)      
    (setvar "clayer" clay)
    (setvar "orthomode" omd)
    (princ)
)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: XREF stamp Deluxe Edition ?
« Reply #7 on: January 25, 2006, 02:41:37 PM »
tblobjname expects a string arguement.  So you would have to get the name of the xref.  So try
Code: [Select]
(setq xrn (tblobjname "block" (cdr (assoc 2 (entget (car xrpk))))))
This will get you the entity name for the xref, within the block table.  After you get that, you will have to use (entget.... to get the enitiy's list.  Then you want to look at (assoc 1.... of that list for the path of the drawing.

ps.  use [ code ] (no spaces) before you code to keep formatting, and [ / code ] (no spaces again) after it.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: XREF stamp Deluxe Edition ?
« Reply #8 on: January 26, 2006, 02:57:49 PM »
Here you go.  I had some free time.  You can change this to meet your needs, but it works for me.
Code: [Select]
(defun c:XrefTextList (/ LayCol Str ss Ent BlkName TblEnt FullPath SysTimeList PathStr cnt tmpStr XrefDate)

(vl-load-com)
(if
 (vl-catch-all-error-p
  (vl-catch-all-apply
   'vla-Item
   (list
    (setq LayCol
     (vla-get-Layers
      (vla-get-ActiveDocument
       (vlax-get-Acad-Object)
      )
     )
    )
    "XrefTextList"
   )
  )
 )
 (vla-Add LayCol "XrefTextList")
)
(setq Str "{\\LXREF NAME | XREF PATH | XREF DATE SAVED}\\P")
(if (setq ss (ssget "x" '((0 . "INSERT"))))
 (while (setq Ent (ssname ss 0))
  (setq BlkName (cdr (assoc 2 (entget Ent))))
  (setq TblEnt (tblobjname "block" BlkName))
  (if (/= (setq Path (cdr (assoc 1 (entget TblEnt)))) "")
   (progn
    (setq FullPath (findfile Path))
    (setq SysTimeList (vl-file-systime FullPath))
    (setq PathStr "")
    (setq cnt 1)
    (while (/= (setq tmpStr (substr FullPath cnt 1)) "")
     (if (= tmpStr "\\")
      (setq PathStr (strcat PathStr "\\\\"))
      (setq PathStr (strcat PathStr tmpStr))
     )
     (setq cnt (1+ cnt))
    )
    (setq XrefDate (strcat (itoa (cadr SysTimeList)) "/" (itoa (cadddr SysTimeList)) "/" (itoa (car SysTimeList))))
    (setq Str (strcat Str BlkName " | " PathStr " | " XrefDate "\\P"))
   )
  )
  (ssdel Ent ss)
 )
)
(if FullPath
 (if (setq ss (ssget "x" '((0 . "MTEXT") (8 . "XrefTextList"))))
  (vla-put-TextString (vlax-ename->vla-object (ssname ss 0)) Str)
  (vlax-put
   (vlax-invoke
    (vlax-get
     (vla-get-ActiveDocument
      (vlax-get-Acad-Object)
     )
     (if (equal (getvar "cvport") 1)
     'PaperSpace
     'ModelSpace
     )
    )
    'AddMText
    (getpoint "\n Select insertion point for Xref text: ")
    0
    Str
   )
   'Layer
   "XrefTextList"
  )
 )
 (prompt "\n No xrefs found in drawing.")
)
(princ)
)

Edit:  Set the new Mtext object to the correct layer.  Had a variable there that wasn't assigned to anything.
Edit:  It was grabbing the "day of the week" instead of the "day of the month".  Fixed now. 2/2/06.  If you have dl'ed a previouse version, you should gab this one.
« Last Edit: February 02, 2006, 12:45:17 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

phoulx

  • Guest
Re: XREF stamp Deluxe Edition ?
« Reply #9 on: January 30, 2006, 02:13:29 PM »
Whoa! That was cool.  Thanks a lot! 

I set aside this afternoon to work on that lisp a bit more and here you may have beaten me to the punch.  I'll post back with what I end up with.

whdjr

  • Guest
Re: XREF stamp Deluxe Edition ?
« Reply #10 on: February 01, 2006, 09:34:54 AM »
You didn't say what version of AutoCad you are using but with the Fields in the newer version you can do this without any programming.  (sorry 'bout that coders  :-()

GDF

  • Water Moccasin
  • Posts: 2081
Re: XREF stamp Deluxe Edition ?
« Reply #11 on: February 01, 2006, 09:42:08 AM »
Tim, great routine.

Works fine, but in 2006 I get the following error message after insertint the text.

 Select insertion point for Xref text: ; error: Parameter not optional

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

T.Willey

  • Needs a day job
  • Posts: 5251
Re: XREF stamp Deluxe Edition ?
« Reply #12 on: February 01, 2006, 11:41:04 AM »
Tim, great routine.

Works fine, but in 2006 I get the following error message after insertint the text.

 Select insertion point for Xref text: ; error: Parameter not optional

Gary
Gary,
Thanks.  You would have to look in the help files, and see what it says for mtext.  All I do is place it there, and then change the layer.

Does it insert the mtext?  If not, then maybe it doesn't like having a width of zero now.  I'm still on A2k4, so I can check to see what mtext can/can't do with ActiveX controls.

I see one thing that looks like it could be wrong in the code.  I put the layer to the variable LayName, but I don't think I ever assign LayName to anything.  I will change it in the post.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: XREF stamp Deluxe Edition ?
« Reply #13 on: February 02, 2006, 12:10:43 PM »
Gary,

Did you get it to work?
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: XREF stamp Deluxe Edition ?
« Reply #14 on: February 02, 2006, 12:28:12 PM »
Tim

Your code works find, the mtext is placed in the drawing.
I was only pointing out the common line error message that follows.

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64