Author Topic: Solved: Routine acts like it works but doesn't  (Read 2022 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Solved: Routine acts like it works but doesn't
« on: August 31, 2023, 12:46:41 PM »
I copied this routine from one that is working. I only needed to change the block name and attvalue. In a test I removed the (princ) to see what returned. It returned the last (setvar "Clayer" Clay) as if it is going all the way through. I ran troubleshooter and it doesn't show anything either.

The block for both routines are located in the same folder and are in the search path.

For some reason the block doesn't get inserted.

Code - Auto/Visual Lisp: [Select]
  1.  
  2. (defun c:InsLatLong (/ osm ss attvalue dims dimsc Clay)
  3.   (defun *error* (msg)
  4.     (if osm
  5.       (setvar 'osmode osm)
  6.     )
  7.     (if (not (member msg '("Function cancelled" "quit / exit abort")))
  8.       (princ (strcat "\nError: " msg))
  9.     )
  10.     (princ)
  11.   )
  12.   (setq osm (getvar 'osmode))
  13.   (setvar 'osmode 0)
  14.   (setvar 'cmdecho 0)
  15.  
  16.   ;| "LM:getattributes" Courtesy of Lee Mac |;
  17.   (defun lm:getattributevalue (blk tag / val enx)
  18.     (while
  19.       (and (null val)
  20.            (= "ATTRIB"
  21.               (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk))))))
  22.            )
  23.       )
  24.       (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
  25.         (setq val (cdr (assoc 1 enx)))
  26.       )
  27.     )
  28.   )
  29.  
  30.   (setq Clay (getvar "clayer"))
  31.   (command "._layer" "Make" "TEXT3" "C" "CYAN" "TEXT3" "")
  32.   (setq dimsc (getvar 'dimscale))
  33.   (setq ss (ssget "x" '((0 . "INSERT") (2 . "TBLK_ATT_CTL") (66 . 1))))
  34.   (setq attvalue (LM:GetAttributeValue (ssname ss 0) "TITLELINE4"))
  35.  
  36.   (cond
  37.     ((wcmatch (strcase attvalue) "SINGLE LINE")
  38.      (command ".-insert" "SU_STA_Ins_LatLong" "0,0" dimsc dimsc "")
  39.         );;wcmatch
  40.    );;end cond
  41.  
  42.   (setvar "clayer" Clay)
  43.  (princ)
  44. )

EDIT:
If I change the attvalue to the attvalue of the code that's working and leave the blockname unchanged the block gets inserted. I can insert any block using the other routine.

Here is that portion of the other routine.

Code - Auto/Visual Lisp: [Select]
  1. (setq dimsc (getvar 'dimscale))
  2.   (setq ss (ssget "x" '((0 . "INSERT") (2 . "TBLK_ATT_CTL"))))
  3.   (setq attvalue (LM:GetAttributeValue (ssname ss 0) "SUFFIX"))
  4.    (cond
  5.     ((wcmatch (strcase attvalue)
  6.               "RM")
  7.      (command ".-insert" "SU_STA_INS_LatLong" "0,0" dimsc dimsc "")
  8.         );;wcmatch
  9.    );;end cond
  10.  
  11.   (setvar "clayer" Clay)
« Last Edit: August 31, 2023, 03:38:32 PM by jlogan02 »
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

jlogan02

  • Bull Frog
  • Posts: 327
SOLVED: Edit: Routine acts like it works but doesn't
« Reply #1 on: August 31, 2023, 03:37:54 PM »
SOLVED: Something to do with the attributed block itself. Tried two different drawings with the same attribute and it works
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2149
  • class keyThumper<T>:ILazy<T>
Re: Solved: Routine acts like it works but doesn't
« Reply #2 on: August 31, 2023, 05:29:26 PM »


>>> Something to do with . . .

That is usually the cause of most errors.
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

jlogan02

  • Bull Frog
  • Posts: 327
Re: Solved: Routine acts like it works but doesn't
« Reply #3 on: August 31, 2023, 06:14:53 PM »
Right!?!?!?
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2149
  • class keyThumper<T>:ILazy<T>
Re: Solved: Routine acts like it works but doesn't
« Reply #4 on: August 31, 2023, 07:35:32 PM »
Right!?!?!?


Sorry, that's just my lack of humor showing.

I had a laugh at the statement
>>> Something to do with . . .

Did you actually find the fault ?


fyi : regarding the file attachment .snagx
not everyone has Snagit, so you should save the capture in the SnagitEditor as a .PNG file prior to attaching it to your post.

Regards,
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

framednlv

  • Newt
  • Posts: 65
Re: Solved: Routine acts like it works but doesn't
« Reply #5 on: September 07, 2023, 01:41:22 PM »
I hope you know that if you have an annotative dim style current, dimscale will always be 1.0, and you can't only set it to 0.

jlogan02

  • Bull Frog
  • Posts: 327
Re: Solved: Routine acts like it works but doesn't
« Reply #6 on: September 11, 2023, 06:15:14 PM »
Yes. I go that reminder when I started testing. Good point.
J. Logan
ACAD 2018

I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10