- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm struggling with rehosting an adaptive point to a geometry, in my case it is a Model Line in a FamilyInstance. The main source of the problem that as some of us knows is getting geometry with references from FamilyInstances is kinda sketchy. I can get the Line in Project Coordinates from the `GeometryElement` got from `GeometryInstance.GetInstanceGeometry()`, however the Reference taken from this Line is in the Family's Coordinate System, and using this Reference as a host for the ReferencePoint moves my Adaptive Component to a completely wrong position.
It is also known, that if I use the Line from `GeometryElement` got from `GeometryInstance.GetSymbolGeometry()` returns the Reference in Project Coordinates (btw in this case the Line object itself will be in the Family's coordinates.... total nonsense). Using this reference for the `PointOnEdge' object for setting the `ReferencePoint`'s element reference with `.SetPointElementReference()` throws an `InternalException` without any interpretable explanation.
Because of the reasons above I've tried using the wrong reference for hosting the RefPoint, and later updating the Position of the Refpoint using the FamilyInstance's Transform, but this wasn't succesfull either, because the RefPoint sticks to the invisible, Family Coordinate System based Reference.
Any tips to solve this?
I've also made a video about how I fail to achieve my goal, please find it attached. 🙂
The code for reference:
adaptive_family = doc.GetElement(DB.ElementId(3787458))
line_family = doc.GetElement(DB.ElementId(3762716))
placementPointIds = DB.AdaptiveComponentInstanceUtils.GetInstancePlacementPointElementRefIds(adaptive_family)
placementPoints = [doc.GetElement(i) for i in placementPointIds]
curves = []
opts = DB.Options()
opts.ComputeReferences = True
gi = next((e for e in line_family.get_Geometry(opts) if isinstance(e, DB.GeometryInstance)), None)
tr = gi.Transform
curve_instance = next((e for e in gi.GetInstanceGeometry() if isinstance(e, DB.Curve)), None)
curve_symbol = next((e for e in gi.GetSymbolGeometry() if isinstance(e, DB.Curve)), None)
curve = curve_instance
with db.Transaction():
for ap in placementPoints:
#if placementPoints.index(ap) > 0: break
ir = curve.Project(ap.Position)
ploc = DB.PointLocationOnCurve(
DB.PointOnCurveMeasurementType.NonNormalizedCurveParameter,
ir.Parameter,
DB.PointOnCurveMeasureFrom.Beginning
)
ref = curve_instance.Reference
#ref = curve_symbol.Reference
poe = doc.Application.Create.NewPointOnEdge(
ref,
ploc
)
ap.SetPointElementReference(poe)
#ap.Position = tr.OfPoint(ap.Position)
Solved! Go to Solution.