spettitt Posted January 20, 2023 Share Posted January 20, 2023 (edited) 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 January 20, 2023 by spettitt Quote Link to comment
michaelk Posted January 20, 2023 Share Posted January 20, 2023 #L# returns the layer of the tagged object. I think that's what you're trying to do? Or is it more complicated? Hoist Tag.vwx Quote Link to comment
Sam Jones Posted January 20, 2023 Share Posted January 20, 2023 It's hard to believe that the data tag doesn't store the handle to the object that it is tagging, but I haven't been able to locate where it is storing that handle. Anybody know where that handle might be stored and how VS might access it? Quote Link to comment
Pat Stanford Posted January 20, 2023 Share Posted January 20, 2023 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); 1 Quote Link to comment
Pat Stanford Posted January 20, 2023 Share Posted January 20, 2023 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. Quote Link to comment
Sam Jones Posted January 20, 2023 Share Posted January 20, 2023 If that is the case, one should be able to cycle through the associations and check the handle for each index until you find a hoist, probably the only association, and then do a GetLayer on the handle of the associated hoist. Quote Link to comment
Pat Stanford Posted January 20, 2023 Share Posted January 20, 2023 Basically what the script I posted does. It just doesn't check if the tag is associated with a Hoist or not. I believe that Data Tags can only have one Association. Quote Link to comment
spettitt Posted January 20, 2023 Author Share Posted January 20, 2023 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 Quote Link to comment
Recommended Posts
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.