Sweep not permitted in a FamilyDOcument

Sweep not permitted in a FamilyDOcument

dirk.neethling
Advocate Advocate
1,683 Views
26 Replies
Message 1 of 27

Sweep not permitted in a FamilyDOcument

dirk.neethling
Advocate
Advocate

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

0 Likes
1,684 Views
26 Replies
Replies (26)
Message 21 of 27

Revitalizer
Advisor
Advisor

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

dirk.neethling
Advocate
Advocate

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

0 Likes
Message 23 of 27

FAIR59
Advisor
Advisor

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
Advisor
Advisor
Accepted solution

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
Advocate
Advocate

Thanks for answering.

How can I find the reference plane of a FamilyInstance?

0 Likes
Message 26 of 27

FAIR59
Advisor
Advisor

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
Advocate
Advocate
Accepted solution

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

0 Likes