Jump to content
Developer Wiki and Function Reference Links ×

Set Data Tag Layer to match tagged Object Layer


spettitt

Recommended Posts

Hello, we use data tags to tag hoists, and the hoists for each truss are on a different layer - LX1 Hoists, LX2 Hoists etc. Trying to keep the Layer of each data tag in sync with the layer of the hoist it is tagging is a nightmare. I need the hoist and the tag to go on/off together, so I'm not left with tag but no hoist.

 

I would to write a script that cycles through all data tags (or the selected data tags, whatever is easier), gets the layer of the object tagged and then sets the layer of the data tag to match.

 

However, I can't find in anything in references for Vectorscript or Marionette of any way towards getting the layer of the tagged object.

 

Does anyone have any ideas please?

Edited by spettitt
Link to comment
  • spettitt changed the title to Set Data Tag Layer to match tagged Object Layer

I don't think that is is Michael.

 

The following script will move every data tag in the file to the same layer as the object that it is tagging.  

 

To only move objects attached to certain types of objects, check for the object type inside the Execute procedure before moving the tag.

 

Change the Criteria in the ForEachObject call to only move tags that meet some criteria.

 

Procedure MoveTags;

{January 19, 2023. Pat Stanford pat@coviana.com}
{Sample of how to get associated object for a data tag}
{and then move the data tag to the layer of that Object}
{No rights reserved. Use at your own risk.}
{No warranty expressed or implied.}

Procedure Execute(Hd1:Handle);
VAR	Hd2,Hd3	:Handle;
	N1, N2	:Integer;
	B1		:Boolean;
	
	BEGIN
		Hd2:=GetAssociation(Hd1,0, N1, N2);
		Hd3:=GetLayer(Hd2);
		B1:=SetParent(Hd1, Hd3);
	End;
	
BEGIN
ForEachObject(Execute,((PON='Data Tag')));
End;

Run(MoveTags);

 

  • Like 1
Link to comment

It is an Association Sam. Not a storing of the handle.

 

There should probably be error checking in the Execute procedure to make sure that Hd2 is not nil and that the tag is actually associated to something.

 

Note that the Associations are zero based. So even though there is one association (determining in my original testing using the GetNumAssociations function but not included in the final script), the Index in the GetAssociation call has to be zero.

Link to comment

Thanks so much everyone, especially @Pat Stanford for the script! It works brilliantly.

 

Actually, having my truss data tags moved to the same layer as the truss system they are tagging is great as well, so it's better that it's unfiltered. I can't think of an edge case where I would expressly want a tag on a different design layer...

 

Thanks again

 

Simon

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