Jump to content

Hide layer of selected object - Help with script


Recommended Posts

Hello, I am trying to write a script so I can right click on an object and hide that object's layer.

Any help would be apprciated since I am very new to scripting and this doesn't work.

 

 

 

PROCEDURE DesactivateLayer;
VAR
    h : HANDLE;
    Selected() : TRUE :
BEGIN
    IF h<>NIL THEN BEGIN
        Layer (GetLName (GetLayer(h)));
        HideLayer;
    END;
END;
RUN(DesactivateLayer);

 

Link to comment

Try this script.  There are other ways, but they are not currently updating the visibility columns in the Navigation Palette. I have submitted a bug.

 

PROCEDURE DesactivateLayer;
VAR
    h1, h2, h3, h4 	:HANDLE;
    X1, Y1			:Real;
    B1				:Boolean;
	N1				:Integer;
	
BEGIN
	h1:=Nil;
	h4:=ActLayer;			{save the active layer}
	B1:=FALSE;
	While Not B1 DO
		BEGIN				{This lets you click multiple times to pick an object}
			GetPt(X1,Y1);
			B1:=GetPickObjectInfo(X1, Y1, h1, h2, N1);  {ignore h2, N1 not needed}
		End;
		
	h3:=GetLayer(h1);		{Get the layer the picked object is on}
	
	Layer(GetLName(h3));  	{make the layer of the object active}
	HideLayer;				{Hide the layer}
	Layer(GetLName(h4));	{respore the original layer to active}
	Redrawall;				{redraw to make sure changes display}
END;

RUN(DesactivateLayer);

 

Link to comment
2 hours ago, setdesigner said:

Hello, I am trying to write a script so I can right click on an object and hide that object's layer.

Any help would be apprciated since I am very new to scripting and this doesn't work.

 

Doesn't the Visibility Tool in Layer Mode | Invisible Mode do this?

 

 

Link to comment

Thanks Pat, this works ! 

Select object

right-click and choose the script ( I have put it in object context menu )

Click again to apply.

 

 

@michaelk you are correct, but I wanted to avoid using a tool, and keep it in a context menu, just like using Lock

 

Link to comment

I too was using a script similar to this to hide classes. I’ve added so many Scripts that I’ve actually hit the limit of Scripts that a workspace can handle and I’ve had to pair down and delete Scripts from my workspace so they would all work. It would be nice if there wasn’t a limit to the workspace because I did like having the script rather than using the visibility tool. 

  • Laugh 1
Link to comment

@The Hamma,

   Out of curiosity, how many scripts is too many? Ball park. I assume the limit depends on how many total items are in a workspace, but knowing how many scripts you added would be interesting to know. Also, were your scripts Menu Items, or Palette Scripts?

 

Thanks,

Raymond

Link to comment
14 minutes ago, MullinRJ said:

how many scripts is too many?

When I export the standard architect workspace there are 911 lines of menu commands. I added 128 additional lines and the last command I added does not work.  I did delete some of the default commands. 

Link to comment
  • 1 month later...
On 4/5/2022 at 8:30 PM, MullinRJ said:

@The Hamma,

   Out of curiosity, how many scripts is too many? Ball park. I assume the limit depends on how many total items are in a workspace, but knowing how many scripts you added would be interesting to know. Also, were your scripts Menu Items, or Palette Scripts?

 

Thanks,

Raymond

I think the number depends on the alignment of the planets, and it will change over time.  I used to have a massive workspace full of custom scripts which made my workflow exceptionally fast.  Then somewhere around 2015, workspaces started to break apart if there were too many scripts. Many just wouldn't run.  This lasted for years.  2021 seemed to fix it, and I loaded up my workspace again, and it worked well.  Then, over time, commands started to break, not work at all, or call up completely random other commands.  I've never figured out an actual number.  Hopefully, 2022 fixes it, but I'm not holding my breath.

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
Reply to this topic...

×   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...