Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Instance with Direction (0,0,1)

6 REPLIES 6
Reply
Message 1 of 7
MarryTookMyCoffe
769 Views, 6 Replies

Instance with Direction (0,0,1)

I have family that I can put in to a revit and then rotate it in every direction without brake it geometry, but when I do it with Api geometry brake(for 0,0,1 evry element appere as a line).

Is there is a way that family should be created?

 

usualy I have this problem with spheres(i have lots of difrent types of valves).

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
6 REPLIES 6
Message 2 of 7

Hi @MarryTookMyCoffe,

You explain that something is wrong, but there's nothing to go on.

What sort of family? Category? What template was the family created from?

How did you insert it? How did you rotate it? etc

 

So many questions.

 

Cheers,

 

-Matt


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 3 of 7

mechanical template, sc1.jpg
category of familys: fitting, accessory, mechanical equipment, hydraulic fittings.

with family build by user(like on picture on right)  and generic fitting.
Now Im doing it by using:

Autodesk.Revit.Creation.FamilyInstanceCreationData FICD = new Autodesk.Revit.Creation.FamilyInstanceCreationData(elementA.point / toMeters, elementA.symbol, elementA.direction, elementA.level, StructuralType.NonStructural);

//and later i Use list of it
NFI2listElemtsdata = doc.Create.NewFamilyInstances2(DataLibrary.Library_elementsdata[Jag]);

I try to insert element with direction (1,0,0) and them rotate it araund it axis but element stretched it self like that:
medium.pngI can rotate it by UI to this position from that same axis, with no problem.

 

Can it be that this appear because, I use level as a host?



pleas don't write that there is function to automatically places fittings.

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
Message 4 of 7

Hi @MarryTookMyCoffe,

To be honest, I'm not much clearer on what sort or family you're trying to place, or how you're trying to rotate it. You left out the rotation code, and obscured the code in objects only understandable to you.

When you place the familyinstance using the UI, what is it hosted on? If it's not hosted on anything, you'll want to use a different NewFamilyInstance overload.

 

If you search for "rotate a column" in the SDK, you'll see an example of how to rotate a familyinstance. If you're newly creating the element, you may need to insert the familyinstance, then either do doc.regenerate or put the rotation in a separate transaction.

 

If you're still having trouble, I suggest posting a family, test model (with correct manual placement), and most importantly a minimum reproducible test case as Jeremy points out here:

http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Cheers,

 

-Matt

 

 


Cheers,

-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?
Message 5 of 7

 

I did some research of how NewFamilyInstance method work, I made a variation of simple family that is just block.
I check almost every combination of family parameters. I did a simple code to test my theories:

 

            // Retrieve elements from database

            FilteredElementCollector colLevel= new FilteredElementCollector(doc).OfClass(typeof(Level));
            FilteredElementCollector colview = new FilteredElementCollector(doc).OfClass(typeof(View));
            FilteredElementCollector col = new FilteredElementCollector(doc)
                .OfCategory(BuiltInCategory.OST_PipeAccessory)
                .OfClass(typeof(FamilySymbol));

            // Filtered element collector is iterable
            FamilySymbol familysymbol = null;
            foreach (FamilySymbol e in col){if(e.Id.IntegerValue == 661863){familysymbol = e;}}
           // if(familysymbol == null){familysymbol = col.FirstElement() as FamilySymbol;}

            // Modify document within a transaction
            Line line = Line.CreateBound(new XYZ(15, 0, 0), new XYZ(15, 1, 0));
            Line line2 = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(1, 0, 0));
            
            Autodesk.Revit.Creation.FamilyInstanceCreationData ficData = new Autodesk.Revit.Creation.FamilyInstanceCreationData(new XYZ(15, 0, 0), familysymbol, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
            ficData.Axis = line;
            ficData.RotateAngle = 90 * Math.PI / 180;
            
            List<Autodesk.Revit.Creation.FamilyInstanceCreationData> dgdf = new List<Autodesk.Revit.Creation.FamilyInstanceCreationData>();
            dgdf.Add(ficData);

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("Transaction Name");
                FamilyInstance fInstance = doc.Create.NewFamilyInstance(line as Curve, familysymbol, colLevel.FirstElement() as Level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);

                FamilyInstance fInstance2 = doc.Create.NewFamilyInstance(new XYZ(5, 0, 0), familysymbol, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
                line2 = Line.CreateBound(new XYZ(5, 0, 0), new XYZ(5, 1, 0));
                fInstance2.Location.Rotate(line2, 90 * Math.PI/180);

                FamilyInstance fInstance3 = doc.Create.NewFamilyInstance(new XYZ(10, 0, 0), familysymbol, new XYZ(0,0,-1), colview.FirstElement(), Autodesk.Revit.DB.Structure.StructuralType.NonStructural);

                doc.Create.NewFamilyInstances2(dgdf);

                FamilyInstance fInstance4 = doc.Create.NewFamilyInstance(new XYZ(20, 0, 0), familysymbol, new XYZ(0, 0, -1),null , Autodesk.Revit.DB.Structure.StructuralType.NonStructural);

                doc.Regenerate();
                tx.Commit();
            }

and i went to conclusion that it is impossible to put any family with any kind of type or category, with direction new XYZ(0,0,1). That's my answer.

 

on plus side I discover that I can in put a Axis and RotateAngle to FamilyInstanceCreationData. Now i only need to do is a method that take right direction and change it for XYplane direction and set axis as perpendicular to it and rotate by the right angle.

 

 

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug
Message 6 of 7
FAIR59
in reply to: MarryTookMyCoffe

Actualy you can rotate families of Category Mechanical Equipment, Pipe Accessories and Pipe Fittings to direction (0,0,1).

 

Place the family with

 

instance = doc.Create.NewFamilyInstance( _location, _Symbol, StructuralType.NonStructural);

 

and rotate using the ElementTransformUtils

 

ElementTransformUtils.RotateElement(doc, instance.Id, Line.CreateBound(_location, _location.Add(XYZ.BasisY)), -Math.PI / 2);

 

Message 7 of 7
MarryTookMyCoffe
in reply to: FAIR59

did you read what I post?
that is no solution, and I already figure out better way than RotateElement.

-------------------------------------------------------------
--------------------------------|\/\/|------------------------
do not worry it only gonna take Autodesk 5 years to fix bug

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community