twk Posted October 14, 2019 Share Posted October 14, 2019 There isn't much script functionality on the DevWiki regarding Data Tags. I was wondering if anyone knew how to get a handle to an object a data tag is attached to. Say I can collect all the data tags in a viewport, as handles, does anyone know how to get handles to objects those data tags are attached to? Cheers, Tui Quote Link to comment
Vectorworks, Inc Employee KIvanov Posted October 16, 2019 Vectorworks, Inc Employee Share Posted October 16, 2019 Hello Tui, I will send you a simple script how this can be done. Best Regards, Kostadin Ivanov Quote Link to comment
twk Posted June 7, 2020 Author Share Posted June 7, 2020 h = Data Tag Object Handle import vs; def GetTaggedObject(h): result = False; num = vs.GetNumAssociations(h); assH = None assKind = None value = None i = 0; while(i < num and result == False): assH, assKind, value = vs.GetAssociation(h, i); if (assKind == 37): result = True; i = i + 1; return result, assH; 1 Quote Link to comment
DomC Posted June 13, 2022 Share Posted June 13, 2022 Hello Someone knows the secret of tagging an object with the DataTag by script? Seems to be not so easy. So far my researches: 1. Read the ASSKINDs of Object and DataTag. It shows me: 37 for the Data-Tag 36 for the Tagged Object obj1 = vs.FSActLayer() num = vs.GetNumAssociations(obj1) out_str = 'Associations\r' for i in range(num): v = str(vs.GetAssociation(obj1, i)) out_str += str(v)+'\r' vs.Message(out_str) 2. Further Assiciations obj1 = vs.FSActLayer() obj2 = vs.NextSObj(obj1) result = vs.AddAssociation(obj1, 17, obj2) #4(deleted if delete), 5(reset if deleted) 17(?) vs.HMove(obj1, 1,0) 3. Remove Associations obj1 = vs.FSActLayer() #stempel = vs.GetObject('stempel') num = vs.GetNumAssociations(obj1) out_str = 'Associations\r' for i in range(num): ioTargetObj, inKind, value = vs.GetAssociation(obj1, i) vs.RemoveAssociation(obj1, inKind, ioTargetObj) 4. Maybe with a constraint? h1 = vs.Handle(0) h2 = vs.GetObject('line1') h3 = vs.GetObject('symbol1') if h2 != vs.Handle(0): p2 = vs.Get2DPt(h2, 0) x1, y1 = vs.HCenter(h3) obj, index, containedObj = vs.GetClosestPt( h3, x1, y1) vs.AlrtDialog(str([obj, index, containedObj, h1, h2, h3])) #obj1 and h1 are the same contObj1 is None bool = vs.SetBinaryConstraint(1, h3, h2, index, -1, 1, -1, containedObj, 0) if h2 != vs.Handle(0) and h3 != vs.Handle(0): bool = vs.HasConstraint(h2) vs.AlrtDialog(str(bool)) This works for a line and a symbol. Maybe this works with data-tags and object also if we could find the right arguments. Quote Link to comment
Vectorworks, Inc Employee KIvanov Posted June 14, 2022 Vectorworks, Inc Employee Share Posted June 14, 2022 Hi @DomC, You can try the function DT_AssociateWithObj. Best Regards, Kostadin Ivanov 2 Quote Link to comment
DomC Posted June 14, 2022 Share Posted June 14, 2022 Oh, direct before my very eyes. Thank you so much, that works perfectly! 1 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.