Author Topic: Insert a slide from a list of slides using att tag value  (Read 176 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 207
Insert a slide from a list of slides using att tag value
« on: May 07, 2021, 04:25:59 PM »
This tested out fine for one slide

Code - Auto/Visual Lisp: [Select]
  1. ;;;  build a list of slides
  2. ;;;  match the slide in the list to the appropriate TitleLine4 tag
  3. ;;;  insert the slide after TitleLine4 has been identified.
  4. ;;;
  5.  
  6.  
  7. (defun C:Slide_Ins ( / )
  8.  
  9. (defun *error* (msg)
  10.     (if osm
  11.       (setvar 'osmode osm)
  12.     )
  13.     (if (not (member msg '("Function cancelled" "quit / exit abort")))
  14.       (princ (strcat "\nError: " msg))
  15.     )
  16.     (princ)
  17.   )
  18.   (setq osm (getvar 'osmode))
  19.   (setvar 'osmode 0)
  20.   (setvar 'cmdecho 0)
  21.   (defun lm:getattributevalue (blk tag / val enx)
  22.     (while
  23.       (and (null val) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk))))))))
  24.        (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
  25.          (setq val (cdr (assoc 1 enx)))
  26.        )
  27.     )
  28.   )
  29.  
  30.   (setq sld1 "Slide-SingleLine.sld")
  31.  
  32.   (setq ss (ssget "x" '((0 . "INSERT") (2 . "TBLK_ATT_CTL") (66 . 1))))
  33.   (setq attvalue (LM:GetAttributeValue (ssname ss 0) "TITLELINE4"))
  34.   (cond ((wcmatch (strcase attvalue) "SINGLE LINE")
  35.         (command "_VSlide" sld1)
  36.    );;end cond
  37.         )
  38.  
  39.         (princ)
  40. )

My start of an attempt to add more Tag values to attvalue & create a list of the matching slides. Have no idea how to make the connection between the attvalue and the required slide variable. Or the proper syntax for the list of slides as a single variable.
Code - Auto/Visual Lisp: [Select]
  1. (defun C:STA_Slide_Ins ( / )
  2.  
  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.   (defun lm:getattributevalue (blk tag / val enx)
  16.     (while
  17.       (and (null val) (= "ATTRIB" (cdr (assoc 0 (setq enx (entget (setq blk (entnext blk))))))))
  18.        (if (= (strcase tag) (strcase (cdr (assoc 2 enx))))
  19.          (setq val (cdr (assoc 1 enx)))
  20.        )
  21.     )
  22.   )
  23.  
  24.                            ;;;need to make the attvalue in TitleLine4 match the slide name in this list
  25.                            ;;;and build the list of slide files.
  26.                
  27.               (setq aslide
  28.                 '(
  29.                   (sld1 "Slide-Single Line.sld")
  30.                   (sld2 "Slide-AC Schematic.sld")
  31.                   (sld3 "Slide-Control Schematic.sld")
  32.                   (sld4 "Slide-Network Diagram.sld")
  33.                   (sld5 "Slide-Panel Layout.sld")
  34.                 )
  35.  
  36.  
  37.   (setq ss (ssget "x" '((0 . "INSERT") (2 . "TBLK_ATT_CTL") (66 . 1))))
  38.   (setq attvalue (LM:GetAttributeValue (ssname ss 0) "TITLELINE4"))
  39.   (cond ((wcmatch (strcase attvalue) "SINGLE LINE,AC SCHEMATIC,CONTROL SCHEMATIC,NETWORK DIAGRAM,PANEL LAYOUT")
  40.  
  41.                  (command "_VSlide" aslide);;where "aslide" is the name of a slide in a directory to be inserted.      
  42.    
  43. );;end cond
  44.  
  45.         (princ)
  46. )

The base for this code comes from routine Lee Mac helped me with a while back that has served me well for a couple other routines. Thought I'd with it as it seems like the proper place to start.
J. Logan
ACAD 2018

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