Jump to content

Recommended Posts

Posted

Hello All,

 

I have an older lisp written by a kind person from this website, (thank you Lee Mac). I was using this lisp with ACAD 2006 and it worked great! Now that my company has moved to ACAD 2008, the lisp does not work properly anymore. I am guessing that maybe the text of a certain command had changed in the upgrade from 06 to 08. Not really sure.

 

In ACAD 06, the lisp works by selecting the Attribute of the Block I am using. If I select any other part of the Block, the command ends. Also I am only allowed to select one Block at a time. Which can be time consuming when I need to change hundreds of them. But the lisp has been very useful none the less.

 

 

 

 

That being said, I have two objectives.

  • Finding a way to get this lisp to work in ACAD 2008. Even if the lisps abilities dont change, just being able to use it in 08 will be very helpful.
  • Next would be asking someone if they are feeling froggie enough to find a way to tweak the lisp to be able to grab several Blocks at once to be renumbered. The renumber order can be random.

I have attached the lisp routine and the Block I use it with. The Attribute part of the Block is the center text, the other text is Dtext. Also I saved it in ACAD 2000 version.

 

P.S. I rewrote this Thread so I could better summerize what i am trying to find, not to double post.

renum.lsp

ACAD-Points Block.dwg

  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

  • Jadeous

    16

  • Lee Mac

    15

  • devitg

    1

Popular Days

Top Posters In This Topic

Posted

Jadeous -

 

Did you see my most recent post to your other thread?

 

EDIT> You sure I wrote that LISP... doesn't look like anything I would write... :P

Posted

Yes, I tried it. No luck. It is much different than the one you gave me that works well in 06.

Posted

The Error I recieve is - "Error. Can't pase text."

Posted

The LISP will of course fail if you select anything in the block other than the attribute, as it uses nentsel for selection.

 

But I cannot see what this LISP achieves over the reNum that I posted in your other thread... :geek:

Posted

In the original thread, The Longer lisp (for lack of a better description, The one attached to this thread) worked very well in 06. The Shorter one I never used. I stuck with the Longer because it worked.

 

So now I just need to figure out why it stopped working when I switched to ACAD 2008. Even if it works exactly as in 06, thats fine with me. The other part about selecting multiple at once, can wait. I just need to be able to use it like i did in ACAD 2006.

Posted

That's what I'm getting at - the code I posted in your other thread should work as requested, with multiple block selection.

 

If you have not tried it, then there is no point in taking this further.

Posted

I have tried the Shorter one. It finishes with a regen and nothing happens. None of the Blocks are numbered. That is why the Longer one was used instead.

Posted
I have tried the Shorter one. It finishes with a regen and nothing happens. None of the Blocks are numbered. That is why the Longer one was used instead.

 

 

There should be no regen - are you sure you are trying this.

Posted

Yes. I tried taht one.

 

Let's start over for a moment.... This is getting very confussing.

 

This is the only Renum lisp I use... The one I need in ACAD 2008

 

(defun c:renum (/ oldPref oldSuf oldStart curText curStr vlaObj keepText)

(vl-load-com)

(defun TTC_Paste(pasteStr keepText / nslLst vlaObj)

(if (setq nslLst(nentsel "\nPaste text >>"))

(progn (cond

((and (= 4(length nslLst))

(= "DIMENSION"(cdr(assoc 0(entget(car(last nslLst))))))); end and

(setq vlaObj (vlax-ename->vla-object (cdr(assoc -1(entget(car(last nslLst)))))))

(setq oldStat (vla-get-Measurement vlaObj))

(if keepText

(if (= (vla-get-TextOverride vlaObj) "")

(setq pasteStr (strcat pasteStr (rtos oldStat (vla-get-UnitsFormat vlaObj) (vla-get-PrimaryUnitsPrecision vlaObj))))

(setq pasteStr (strcat pasteStr (vla-get-TextOverride vlaObj)))))

(if (vl-catch-all-error-p(vl-catch-all-apply 'vla-put-TextOverride(list vlaObj pasteStr)))

(princ "\n Can't paste. Object may be on locked layer. "))); end condition #1

((and (= 4(length nslLst))

(= "ACAD_TABLE"(cdr(assoc 0(entget(car(last nslLst))))))); end and

(setq vlaObj (vlax-ename->vla-object(car nslLst)))

(if keepText (setq pasteStr (strcat pasteStr (vla-get-TextString vlaobj))))

(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-TextString(list vlaObj pasteStr)))

(princ "\nError. Can't pase text. ")(entupd (car(last nslLst))))); end condition # 2

((and (= 4(length nslLst))

(= "INSERT"(cdr(assoc 0(entget(car(last nslLst))))))); end and

(princ "\nCan't paste to block's DText or MText. ")); end condition #3

((and (= 2(length nslLst))

(member(cdr(assoc 0(entget(car nslLst)))) '("TEXT" "MTEXT" "ATTRIB" "ATTDEF"))); end and

(setq vlaObj (vlax-ename->vla-object(car nslLst)))

(if keepText (setq pasteStr (strcat pasteStr (vla-get-TextString vlaobj))))

(if (vl-catch-all-error-p (vl-catch-all-apply 'vla-put-TextString(list vlaObj pasteStr)))

(princ "\nError. Can't pase text. "))); end condition #4

(T (princ "\nCan't paste. Invalid object. ")); end condition #5

); end cond

T); end progn

nil); end if

);_TTC_PASTE

(setq aDoc(vla-get-ActiveDocument(vlax-get-acad-object)))

(vla-StartUndoMark aDoc)

(if(not rnm:Pref)(setq rnm:Pref ""))(if(not rnm:Suf)(setq rnm:Suf ""))

(if(not rnm:Start)(setq rnm:Start 1))

(setq oldPref rnm:Pref oldSuf rnm:Suf oldStart rnm:Start); end setq

(setq rnm:Pref (getstring T (strcat "\nType prefix: : ")))

(if(= "" rnm:Pref)(setq rnm:Pref oldPref))(if(= " " rnm:Pref)(setq rnm:Pref ""))

(setq rnm:Suf (getstring T (strcat "\nType suffix: : ")))

(if(= "" rnm:Suf)(setq rnm:Suf oldSuf));(if(= " " rnm:Suf)(setq rnm:Suf ""))

(setq rnm:Start (getint (strcat "\nEnter start number

(itoa rnm:Start)">: ")))

(if(null rnm:Start)(setq rnm:Start oldStart))

(initget "Yes No Ä

Posted

Jadeous,

 

For your purpose, the LISP that you have posted will need a complete re-write, which is why I am trying to get the "shorter" one to work (which is a much better way to accomplish your task).

 

If you have tried it, what error do you receive? Or what happens (or not happens)?

Posted

error reads - "ActiveX Server returned an error: Element not found"

Posted
error reads - "ActiveX Server returned an error: Element not found"

 

That is weird, as the code is very simple - there really isn't much that can go wrong...

Posted

Where does it crash? If you run it in the Visual LISP Editor in ACAD, perhaps using the Animate option, where does it fail?

Posted
it stops at nil

 

nil? Nil does not appear anywhere in the code...

Posted

I think it has something to do with the fact that 06 recognizes the Attribute in the Block and 08 thinks it is just dtext or mtext.

Posted
I think it has something to do with the fact that 06 recognizes the Attribute in the Block and 08 thinks it is just dtext or mtext.

 

I've never come across that before, so does this work on '06?

Posted
Yes it does.

 

Then I cannot fault the code - as I say there really isn't much that can go wrong with the code.

 

Just out of interest, could you (in ACAD 2008 ) try this code and post what the command line returns?

 

(defun c:test (/ ent obj atts tag val)
 (vl-load-com)
 
 (if (and (setq ent (car (entsel "\nSelect Block: ")))
          (eq "INSERT" (cdr (assoc 0 (entget ent)))))
   (progn

     (setq obj (vlax-ename->vla-object ent))
     (princ "\n** Entity Converted to VLA-Object **")

     (setq atts (vlax-invoke obj 'GetAttributes))
     (princ "\n** Attributes Obtained **")

     (setq tag (vla-get-TagString (car atts)))
     (princ (strcat "\n** Attribute Tag: " tag " **"))

     (setq val (vla-get-TextString (car atts)))
     (princ (strcat "\n** Attribute Value: " val " **"))))

 (princ))

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