Jump to content
Developer Wiki and Function Reference Links Read more... ×
grant_PD

publish script to turn off classes?

Recommended Posts

I have a client who needs me to publish full sets of plates without any dimensions or notes.  Lucky for me I keep all of my notes in a separate class.  But I'm wondering if there is a script I can use to toggle this global change?  Ideally I'd set up the drawing set, publish in pdf, publish in dwg, run the script to turn off the dims and notes, publish again, run the script to turn back on dims and notes.  

Share this post


Link to post

It's possible, though I would recommend just duplicating all your sheet layers, as technically your drawing set consists of two full sets of plates.  You may also want to adjust the title block to indicate if this is a sheet that should have notes or not.

 

To turn off your classes, use the Visibilities mode of the Organization dialog.  You should be able to toggle visibility in all your duplicated viewports at once.

 

When you Publish, save two sets of sheets, and you can easily toggle between the two in the Publish dialog.

 

-Josh

Share this post


Link to post

If you still want a script...:

 

Procedure ClassToggle;

CONST

kTestClass = 'NonPlot-Loci';

VAR
  VisStatus : INTEGER;

BEGIN

VisStatus := GetCVis(kTestClass);
IF VisStatus=0 THEN HideClass(kTestClass) ELSE ShowClass(kTestClass);

Layer(GetLName(ActLayer));

END;

RUN(ClassToggle);

 

(Just change "NonPlot-Loci" to be the Class you're wanting to control.

Edited by C. Andrew Dunning
  • Like 1

Share this post


Link to post

Actually, not quite so easy if we're talking sheets and viewports.  You have to step through each viewports and run GetVPClassVisibility() /  SetVPClassVisibility() to toggle the class.

Share this post


Link to post

Good catch, Josh.

 

Try this, instead:

 

Procedure ClassToggle2;

CONST
 kTestClass = 'NonPlot-Loci';
 kClassON = 0;
 kClassOff = -1;
 kClassGray = 2;

VAR
 DialogVisState : BOOLEAN;
 VisState : INTEGER;

  PROCEDURE ClassSwitch(H:HANDLE);

  BEGIN
   IF SetVPClassVisibility(H,kTestClass,VisState) THEN BEGIN END;
  END;

BEGIN
 DialogVisState := YNDialog(Concat('Do you want the Class "',kTestClass,'" visible?'));
 IF DialogVisState THEN VisState := kClassON
   ELSE
  VisState := kClassOff;
 ForEachObject(ClassSwitch,(ST=REGVIEWPORT)); 
END;

RUN(ClassToggle2);

  • Like 1

Share this post


Link to post
On 9/7/2017 at 8:05 PM, C. Andrew Dunning said:

If you still want a script...:

 

Procedure ClassToggle;

CONST

kTestClass = 'NonPlot-Loci';

VAR
  VisStatus : INTEGER;

BEGIN

VisStatus := GetCVis(kTestClass);
IF VisStatus=0 THEN HideClass(kTestClass) ELSE ShowClass(kTestClass);

Layer(GetLName(ActLayer));

END;

RUN(ClassToggle);

 

(Just change "NonPlot-Loci" to be the Class you're wanting to control.

 

Thanks for this. How do you add a Design Layer as well? So you can toggle a design layer + class.

Share this post


Link to post
On 11/2/2018 at 7:20 PM, C. Andrew Dunning said:

Christiaan -

 

It is the same syntax, except for using "GetLVis," "HideLayer," and "ShowLayer."

Make sense?

 

 

I tried this but I'm getting at error (have no idea what I'm doing!):

Procedure ClassToggle;
CONST
kTestClass = 'NonPlot-Brick grid';
VAR
  VisStatus : INTEGER;
BEGIN
VisStatus := GetCVis(kTestClass);
IF VisStatus=0 THEN HideClass(kTestClass) ELSE ShowClass(kTestClass);
Layer(GetLName(ActLayer));
END;
RUN(ClassToggle);

Procedure LayerToggle;
CONST
kTestLayer = 'BRICK GRID';
VAR
  VisStatus : INTEGER;
BEGIN
VisStatus := GetLVis(kTestLayer);
IF VisStatus=0 THEN HideLayer(kTestLayer) ELSE ShowLayer(kTestLayer);
Layer(GetLName(ActLayer));
END;
RUN(LayerToggle);

 

Share this post


Link to post

Try this, instead:

 

Procedure LayerToggle;
CONST
kTestLayer = 'BRICK GRID';
VAR
  VisStatus : INTEGER;
  ActLayerName : STRING;
 
BEGIN
ActLayerName := GetLName(ActLayer);
VisStatus := GetLVis(GetLayerByName(kTestLayer));

Layer(kTestLayer);

IF VisStatus=0 THEN HideLayer ELSE ShowLayer;

Layer(ActLayerName);
END;
RUN(LayerToggle);

  • Like 1

Share this post


Link to post

Thanks C, how do I include the layer ("BRICK GRID") and the class ("NonPlot-Brick grid") in the same script?

Edited by Christiaan

Share this post


Link to post

Try this:

 

Procedure LayerClassToggle;

CONST
 kClass = 'NonPlot-Brick grid';
 kLayer = 'BRICK GRID';
 kON = 0;
 kOff = -1;

VAR
 LayerVisStatus,ClassVisStatus : INTEGER;
 ActLayerName     : STRING;
 DialogVisState     : BOOLEAN;

BEGIN
 ActLayerName := GetLName(ActLayer);
 LayerVisStatus := GetLVis(GetLayerByName(kLayer));

 Layer(kLayer);
 IF LayerVisStatus=0 THEN HideLayer ELSE ShowLayer;

 ClassVisStatus := GetCVis(kClass);
 IF ClassVisStatus = 0 THEN HideClass(kClass) ELSE ShowClass(kClass);
 
 Layer(ActLayerName);
 END;

RUN(LayerClassToggle);

  • Like 2

Share this post


Link to post

Any idea how to make sure they're synced when the toggle is activated? As it stands if the layer is off and the class is on, it will simply swap this around to layer on, class off. 

 

The logic I'm after is:

1. If either layer or class is off, then toggle both layer and class on

2. If both layer and class is on, then toggle them both off

Share this post


Link to post

Here's what might be a better approach:

 

Procedure LayerClassToggle;

CONST
 kClass = 'NonPlot-Brick grid';
 kLayer = 'BRICK GRID';

VAR
 ActLayerName      : STRING;
 ClassLayerVisible   : BOOLEAN;

BEGIN
 ClassLayerVisible := YNDialog(Concat('Do you want the Class "',kClass,'" and the Layer "',kLayer,'" visible?'));

 ActLayerName := GetLName(ActLayer);
 
 IF ClassLayerVisible THEN
  BEGIN
   Layer(kLayer);
   ShowLayer;
   ShowClass(kClass);
  END
    ELSE
   BEGIN
    Layer(kLayer);
    HideLayer;
    HideClass(kClass);
   END;
 Layer(ActLayerName);
END;

RUN(LayerClassToggle);

  • Like 1

Share this post


Link to post

That pop-up by-passes testing which is visible or invisible (Class or Layer) and simply makes them both the state you choose.  That way, VW doesn't have to read your mind...  ;-)

Share this post


Link to post

But it doesn't need to read my mind, it only needs to test for the following:

1. If either layer or class is off, then toggle both layer and class on

2. If both layer and class is on, then toggle them both off

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×