Author Topic: Set Workspace by attribute tag  (Read 1241 times)

0 Members and 1 Guest are viewing this topic.

jlogan02

  • Bull Frog
  • Posts: 327
Set Workspace by attribute tag
« 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?


J. Logan
ACAD 2018

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

Rustabout

  • Newt
  • Posts: 135
Re: Set Workspace by attribute tag
« Reply #1 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.

jlogan02

  • Bull Frog
  • Posts: 327
Re: Set Workspace by attribute tag
« Reply #2 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...
  • Check if profile exists
  • Check if workspace exists
  • load what doesn't exist
  • get titleline4 tag text
  • set workspace from titleline4 get

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.



 
J. Logan
ACAD 2018

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