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
Solved! Go to Solution.
Solved by dirk.neethling. Go to Solution.
Solved by FAIR59. Go to Solution.
Solved by Revitalizer. Go to Solution.
Solved by Revitalizer. Go to Solution.
Solved by Revitalizer. Go to Solution.
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
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
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();
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 !!!
Thanks for answering.
How can I find the reference plane of a FamilyInstance?
The method creates a Reference Plane and places (hosts) the familyInstance on that plane.
You can find the reference plane as follows:
FamilyInstance.Host
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.