Jump to content

Data Tags


twk

Recommended Posts

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

 

 

Link to comment
  • 7 months later...

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;

 

  • Like 1
Link to comment
  • 2 years later...

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.
 

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