Welcome to the COE Discussion Forum! 

 

To participate in the discussion forum, you must be logged in to the website.  If you forget your login information, please contact COE Headquarters at coe@coe.org or (800) 263-2255.

If you are new to the COE Discussion Forum and would like to participate, please register.


Register Today
COE 2009 Annual PLM Conference & TechniFair

COE DISCUSSION FORUM
Subject: How2 unlink...

You are not authorized to post a reply.   
Author Messages
COE-FORUM-USER

30 Jun 2003 05:42 AM
Hello, everybody!

My current task is to relink selected object from one parent to another. Because I'm new in ST Object Model Programming (after API :), I have a question about it.

OK, I can link selected object to another object now. But I cannot remove link with old parent(s) (unlink object). I try to do like this:

SelectedClassId = SelectedObj.ValueAsInteger("CLASS_ID", 0)
SelectedObjId = SelectedObj.ValueAsInteger("OBJECT_ID", 0)
Set DeletingObj = SmSession.ObjectStore.RetrieveObject(SelectedClassId, SelectedObjId)

'Get parents of selected object
Set ParentObjects = DeletingObj.RetrieveParents(myDef)

'Remove links from parents to selected object
DelLinkClassId = DeletingObj.SmClass.DefaultHierachicalClassId
For i=1 To ParentObjects.Count
ParentObjTemp = ParentObjects.Item(i)
DeletingObj.UnlinkRelation DelLinkClassId, ParentObjTemp
Next i


ST gives me an error in string before last. What I'm doing wrong?

Thanks beforehand for answer

WBR, Vladislav Skoupski
almost ;-) independent developer

Author: Vladislav Skoupski
JOBY


27 Sep 2007 12:39 PM
A shot in the dark...is Vladislav still around?
Does anyone have a canned script that does this?
I'm not lazy, but the API has a steep learning curve...
Thanks!
~Joe

View Joe Burch's profile on LinkedIn
HALE


29 Sep 2007 12:14 AM
Joby,

I don't have an answer for you (and I will send you the scripts you asked for this weekend). I'm wondering why the forum count shows three messages when there are only two. (After I send this it will probably say that there are 4 messages.)

Strange.

Regards,
Hale

Badencorp - CATIA/SmarTeam - Installation, Training and Support!
An hour of hard work can often save you 60 seconds on Google.
PIANNACCHIONE


01 Oct 2007 12:57 PM
I think you're over complicating it. All you need do is get the "link" object (the record in the link table) and issue the delete method... Example

DeletingObj.Delete

Or you can also define a behavior if you want it to go "quietly..."

Dim linkBehavior As ISmBehavior
linkBehavior = DeletingObj.Session.ObjectStore.DefaultBehavior.Clone
linkBehavior.ConfirmOperations = ConfirmOperationEnum.coYesToAll
DeletingObj.DeleteEx(linkBehavior)

FYI - I didn't test the code above (but it should work)
ciao
Peter

You are not authorized to post a reply.
Forums > COE Forums > SmarTeam > How2 unlink...



ActiveForums 3.6

    

401 North Michigan Avenue, Chicago, IL 60611-4267 | (312) 321-5153 | (800) COE-CALL (U.S.)