Jump to content
  • 5

Renaming Viewports - Is this really not possible from the Navigation Palette?


Kevin McAllister

Question

Is it really not possible to rename a SLVP from the Viewports tab of the Navigation Palette? I right click and choose edit but there's no field for the name of the viewport. I can edit the name of the drawing associated with the viewport. It seems like the only way to rename a SLVP is to select the viewport individually and rename it in the OIP. Am I missing something?

 

Kevin

  • Like 3
Link to comment

Recommended Posts

  • 0

@Matt Panzer Thanks for submitting this!  I've been testing different theories.

 

My guess is that renaming (and that's all this script does) is somehow deleting the Back Reference on the section viewports.  The section lines are still linked to the correct viewports, and will update when refreshed by other methods.

 

I'm hoping that this 8 line script doesn't have to become event aware 🙂.  

Link to comment
  • 0
  • Vectorworks, Inc Employee
15 hours ago, michaelk said:

@Matt Panzer Thanks for submitting this!  I've been testing different theories.

 

My guess is that renaming (and that's all this script does) is somehow deleting the Back Reference on the section viewports.  The section lines are still linked to the correct viewports, and will update when refreshed by other methods.

 

I'm hoping that this 8 line script doesn't have to become event aware 🙂.  

 

I played around with your script and cannot find any trick to fix it.  I think we may need to wait for a fix.

Link to comment
  • 0

@Boh & @Andy Broomell, thanks for finding this bug!  I should send you two all my tools 🙂.

 

I haven't found a way to script around it (yet).  Until then here are two scripts that may help:

 

1.  A version of the renaming script that only renames regular viewports and not section viewports.  As far as I can tell, renaming regular viewports doesn't cause the bug.

 

2.  A script to force already discombobulated section lines to update.  Thanks @Matt Panzer!

 

 

VP Rename Scripts Temp Fix.vwx VP Rename Scripts Temp Fix v2018.vwx

  • Like 1
Link to comment
  • 0
On 2/17/2021 at 7:06 PM, Andy Broomell said:
On 2/17/2021 at 3:52 PM, Boh said:

How are you managing vp names

I'm mostly just not 😅

 

(all the while cursing Vectorworks for the dumb way it currently names them.)

 

As a set designer I have to pump out many drawings quickly, meaning a file might not be used by me for long, in which case it's not always worth the time naming viewports in a useful way. Without the script to do it for me I can't really waste time on it. (Depends on the file of course.)

 

When it comes to linking markers, I make heavy use of the search field in the Linked Viewport dropdown, which is a godsend.

 

Hopefully one day Viewport auto-naming will exist in a smart and useful way, and until then I'll send positive thoughts in the direction of the brilliant michaelk so that perhaps a scripting solution will be found for 2021.

Thanks Andy. Yes I agree that a built in way to auto control vp naming is overdue. Meanwhile MichaelK's scripts are also a godsend!

 

Cheers

Link to comment
  • 0

@Boh You keep breaking my stuff!!!  😆
 

I don't think I've used a detail viewport in a long time.  Probably never in a real work drawing.  Can you send me a file with one right before you run the script?  It looks like the same or similar problem as section viewports.  I'll see if there's a way to exclude detail viewports as well.

 

 

Link to comment
  • 0

I have a question about this script...

It renames viewports in the format:

 

Layer Name > Drawing no. > drawing title

 

But I would like to name my viewports:

 

Layer Name > Class of viewport > Drawing no.

 

Is that something that could be done with a simple alteration to the script?

 

 

 

(By the way, this is as part of a workaround to a slightly annoying behaviour in VW when I am naming viewports, which is that although viewports don't have to have a unique "Drawing Title" I am not able to batch-change the "Drawing Title" by selecting a number of viewports and then typing my desired drawing title into the relevant field. VW will let me type something in there, but it doesn't then apply it to all of the selected viewports. Unless I am missing something.)

Link to comment
  • 0

This should do it:

 

Procedure ViewportRename;

{Updated 15 November 2021 for line-weight}

{Badly Scripted by Michael Klaers.  Updated Aug 2, 2015}

{This script will take all selected viewports and change the name of those viewports to be

        (Sheet Layer) (Viewport Class) (Drawing Number)

This version tries to force the name to appear immeidately in the name field, data tab, OIP when only one VP is selected.

Prior to this version the new name appeared immediately in the Nav Palette, but not in the name field.}

    Var
    VPDwgTitle,VPName,BText,VPNum, VPClass : String;    
    h,hh:  Handle;
    ViewportLayer: Handle;
    ViewportLayerString: String;

    Procedure RenameVP(h : HANDLE);
Begin                            {***********  BEGIN Procedure  ***********}    
    ViewportLayer:= GetLayer(h);
    ViewportLayerString:= GetLName(ViewportLayer);
    VPClass := GetClass(h);
    VPDwgTitle := GetObjectVariableString(h, 1032);
    VPNum := GetObjectVariableString(h, 1033);
    ResetObject(h);


{    Message('Viewport Handle: ',h,chr(13), 
            'Layer Handle: ',ViewportLayer,chr(13),
            'Layer Name: ',ViewportLayerString,chr(13),
            'VP Num: ',VPNum,chr(13),
            'VP Name: ',VPDwgTitle);
}


    SetName(h, CONCAT(ViewportLayerString,' ',VPClass,' ',VPNum));

    SetDSelect(h);        {These two commands are just here to force the new name to appear in the }
    SetSelect(h);        {name field immediately.  They can be deleted w/o consequence}

End;                            {***********  END Procedure  ***********}

Begin                            {***********  Main Program  ***********}    

    ForEachObject(RenameVP,(((T=VIEWPORT))));

End;

Run(ViewportRename);

  • Like 1
Link to comment
  • 0

Thanks, that's very good of you!

 

It seems to work; the only thing is that it acted on all viewports rather than just the selected one like a previous iteration of your script (which I have) did. However, I could see that I just needed to change the line near the end to

 

ForEachObject(RenameVP,(((T=VIEWPORT) & (SEL=TRUE))));

 

and now it works on selected viewports only.

 

I notice it takes quite a long time to run (about 15-20 seconds) even if I just have one viewport selected ... is that what you would expect? Is it because it has to check every viewport in the document to see if it's selected, something like that?

Link to comment
  • 0

Nice job figuring it out!

 

I don't know why it doesn't run instantly.  I tested it on my computer and there is no noticeable run time.  If I get time this week, I'll test it on a file with a ton of viewports.

 

If you want to experiment, try changing SEL=TRUE to VSEL=TRUE.  That will only look at visible selected viewports.  It's possible - and even likely - that there are viewports you can't see that are also selected.  

 

Seven years ago when I wrote the script I knew just enough to be dangerous. 🙂 

Link to comment
  • 0
38 minutes ago, michaelk said:

Seven years ago when I wrote the script I knew just enough to be dangerous

So now you know just enough to be lethal! 🙂 

 

I use these scripts all the time. It’s crazy vw doesn’t have an in built vp naming tool.

 

I did notice the delay in larger files so will try the tweak you mentioned earlier. Thanks

Link to comment
  • 0

So just did a test using the revised script to rename a single selected viewport on a file with ~40 viewports including dlvps and it took about 2 seconds, ...then a test on a file with ~200 viewports including referenced viewports and it took just on 1 minute...

 

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...