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: 

Sweep not permitted in a FamilyDOcument

26 REPLIES 26
SOLVED
Reply
Message 1 of 27
dirk.neethling
1080 Views, 26 Replies

Sweep not permitted in a FamilyDOcument

I am trying to create a FamilyDocument, which should contain a combination of swept profiles, depending on Input.

I am using an existing FamilyDocument (*.rfa) as template.

I have successfully tested the code for sweeping in the FamilyDocument, however when I remove some unwanted, unrelated passive Families from that document, I can no longer create the sweep.

So my quetion is: what conditions are necessary for me to be able to create a sweep?

Regards, Dirk

26 REPLIES 26
Message 21 of 27

Hi Dirk,

 

I've read all the forum postings so far, starting with the first one.

Whenever possible, I make a comment or give a hint.

 

But I've nearly no time at the moment (for diving deeper into the topic).

Perhaps at the weekend...

 

 

Sorry,

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 22 of 27

I tried a template from the English collections Folder, "Metric Generic Model Adaptive". Using this I managed to create a Family and place it in a Project document, superimposing it with the tunnel segment ring. By superimposing both rings, I should obtain the "Segment ring with seals". For some strange reason the sweep command is disregarded, so that the seal is no longer visible. But at least it is drawing the ModelLines along which the seal should be placed, and I can instantiate a Family. However, when I apply a Rotation to the familyInstance,

                ElementTransformUtils.RotateElement(doc, fiProfile.Id, axis, angle);

 

, it does not respond. It only responds to Translation.

What needs to happen in the adaptive component so that it can rotate?

Regards, Dirk

adaptive_el.png

Message 23 of 27
FAIR59
in reply to: dirk.neethling

In Architecture I normally use upright families. When I need to place tilted families in the UI, I place them on a reference plane.

 

This method emulates that behavior

 

        public FamilyInstance PlaceInstance(FamilySymbol symb, XYZ placementPoint, XYZ planeNormal, XYZ instHandDirection, bool OnReferencePlane = true)
        {
            if (symb == null) return null;
            Document doc = symb.Document;
            Family _family = symb.Family;
            if (_family.FamilyPlacementType != FamilyPlacementType.WorkPlaneBased) return null;
            if (planeNormal.IsAlmostEqualTo(XYZ.Zero)) planeNormal = new XYZ(0, 0, 1);
            if (instHandDirection.IsAlmostEqualTo(XYZ.Zero)) instHandDirection = new XYZ(1, 0, 0);
            if (planeNormal.DotProduct(instHandDirection).CompareTo(0) != 0) return null; // check instHandDirection perpendicular to planeNormal.
            ReferencePlane refPlane = null;
            FamilyInstance _instance1 = null;
            XYZ YVec = planeNormal.CrossProduct(instHandDirection).Normalize();
            using (SubTransaction trn = new SubTransaction(doc))
            {
                trn.Start();
                refPlane = doc.Create.NewReferencePlane(placementPoint.Add(instHandDirection), placementPoint, YVec, doc.ActiveView);
                refPlane.Name = "ref" + Guid.NewGuid().ToString();
                _instance1 = doc.Create.NewFamilyInstance(refPlane.GetReference(), placementPoint, instHandDirection, symb);
                trn.Commit();
            }
            if (!OnReferencePlane)
            {
                using (SubTransaction trn = new SubTransaction(doc))
                {
                    trn.Start();
                    doc.Delete(refPlane.Id);
                    trn.Commit();
                }
            }
            return _instance1;
        }

The method requires an open transaction.

 

The family must be WorkplaneBased  and "non" AlwaysVertical.

planeNormal needs to be perpendicular to instHandDirection

 

When creating the family through the API use:

 

FamilyDocument.OwnerFamily.get_Parameter(BuiltInParameter.FAMILY_ALWAYS_VERTICAL).Set((int) 0);

FamilyDocument.OwnerFamily.get_Parameter(BuiltInParameter.FAMILY_WORK_PLANE_BASED).Set((int)1);

 

for upside down placement use

planeNormal = XYZ.BasisZ.Negate();

Message 24 of 27
FAIR59
in reply to: FAIR59

Further information on last Post:

 

You can use the Metric Generic Model or the  M_Allgemeines Modell (they should be the same).

 

When you want to rotate the family in the project (after placing) , you can rotate the reference plane and that will result in rotating the family !!!

Message 25 of 27
dirk.neethling
in reply to: FAIR59

Thanks for answering.

How can I find the reference plane of a FamilyInstance?

Message 26 of 27
FAIR59
in reply to: dirk.neethling

The method creates a Reference Plane and places (hosts) the familyInstance on that plane. 

 

You can find the reference plane as follows:

 

FamilyInstance.Host   

Message 27 of 27
dirk.neethling
in reply to: FAIR59

This solution is wrong, I eventually used the M_Mechanische Geräte template 

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

Post to forums  

Forma Design Contest


Rail Community