TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: jlogan02 on December 23, 2020, 06:52:51 PM

Title: Set Workspace by attribute tag
Post by: jlogan02 on December 23, 2020, 06:52:51 PM
I want to set a workspace current based on what my "TitleLine4" tag says in an attributed title block.

The workspace would already exist.
Single Line
Wiring Diagram
Schematic

TitleLine4 is created when the drawing is loaded...
Single Line
Wiring Diagram
Schematic
So...

This prompts to set current workspace.

Code - Auto/Visual Lisp: [Select]
  1. (defun _WSCURRENT (workspace)
  2.   ;; Example:
  3.   ;;(_WSCURRENT "SINGLE LINE")
  4.          (vl-catch-all-apply 'setvar (list 'wscurrent workspace))
  5.        )
  6.   )
  7. )

Thought about using wcmatch...

An approximation here...

Code - Auto/Visual Lisp: [Select]
  1.   (setq ss (getvar 'WSCURRENT)) ;;;this would have to return the list of workspaces, to work, not just the current workspace.
  2.   (setq attvalue (LM:GetAttributeValue (ssname ss 0) "TITLELINE4"))
  3.   (cond ((wcmatch (strcase attvalue) "SINGLE LINE")
  4.  (command "workspace" "c" ss)
  5.  

I know it's possible to get the list of workspace, but what I've found is over my head.

Has anyone done any work with workspaces?


Title: Re: Set Workspace by attribute tag
Post by: Rustabout on December 24, 2020, 12:27:18 AM
Getting a list of workspaces might be quite difficult and you might need Visual LISP. I know you can check if it exists or not, from that you could build a list.

Based on your needs you might not even need the 'list' especially if you are diligent in creating the workspaces on each workstation.

Your code as described is a good idea and it looks like you're close to getting it to work.
Title: Re: Set Workspace by attribute tag
Post by: jlogan02 on December 24, 2020, 11:28:42 AM
I was building this as an example of what we could do.
It'll show this to the powers that be and see if it sticks.

I'm way out of everyone's comfort level with this type of stuff and I know this will be a hard no, but I like to show them possibilities so they aren't stuck in 1999.

As I see it...

Simple test with dos_listbox.

Code - Auto/Visual Lisp: [Select]
  1. (defun c:wspc ( / wspc )
  2. (if (setq wspc (dos_listbox "WorkSpace Setup" "Select WorkSpace"
  3.                                         '("Single Line")
  4.       )
  5.      )
  6.         (command "workspace" "c" WSPC)
  7.    )
  8.  (princ);;Not the purple rain guy!!!
  9.   )

Thanks for your reply.

Merry Christmas

J.