Is it possible to lock a detail line to a duct through the API? If so how can I do it?
Revit API provides the NewAlignment() method to lock two references. The Revit API chm file provide some details on this method and the FamilyCreation SDK samples provides some code that illustrates the API usage.
The following blog-post too contains more details on using this API.