简体   繁体   中英

Revit 2014 API PromptForFamilyInstancePlacement method

i am trying load Revit files using loadrevitfamily() and wants the user to place specific family symbol on current project in Revit. my code is follows:

public void loadRevitFamily(String f)
    {
        //Filename without extension
        String fname = Path.GetFileNameWithoutExtension(f);

        Family family = null;
        FamilySymbol familyFound = null;

        Transaction t = new Transaction(s_document, "Test");
        t.Start();

        s_document.LoadFamily(f, out family);
        t.Commit();
        FilteredElementCollector familyCollector = new FilteredElementCollector(s_document);
        familyCollector.OfClass(typeof(FamilySymbol));

        foreach (FamilySymbol sym in familyCollector)
        {
            if (sym.Family.Name == fname)
            {
                familyFound = sym;
            }
        }
        UIDocument uidoc = new UIDocument(s_document);
        uidoc.PromptForFamilyInstancePlacement(familyFound);
    }   

but it is not allowing me to place the symbol. Any help please.

I believe this has to do with how the family you are trying to place is hosted (face, workplane, vertical face, etc). In Revit 2014 & earlier PromptForFamilyInstancePlacement won't let the user change the hosting method, change views, etc. Try placing a family that is unhosted and see if you get the same result. You could also have a look at this workaround.

http://thebuildingcoder.typepad.com/blog/2015/03/postrequestforelementtypeplacement.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM