Creating new assembly and adding constraint

Hello, 1) I have to create a new assembly with parent and child relationship but I am not able to add assembly component and with its child component. 2) Also, Constraining it with parent and child component. I could not get the moveable geometry to create constraint for align by axis. In Journal, I have got this geometry"(NXOpen.DatumAxis)workPart.FindObject("Z Axis of Datum Coordinate System(0)");" but I could not edit or fetch this from NX and cannot be used. Thank you in advance.

// Constraint Infer Align by Axis

NXOpen.Positioning.ComponentPositioner CompPosit = workPart.ComponentAssembly.Positioner;

NXOpen.Positioning.Constraint Const1 = CompPosit.CreateConstraint(true);

NewCSYS.GetDirections(out xDirection1, out yDirection1);

NXOpen.Positioning.ComponentConstraint CompConst = (NXOpen.Positioning.ComponentConstraint)Const1;
CompConst.ConstraintAlignment = NXOpen.Positioning.Constraint.Alignment.InferAlign;

CompConst.ConstraintType = NXOpen.Positioning.Constraint.Type.Touch;
Point3d Point1 = new Point3d(0, 0, 0);
Vector3d Vector1 = new Vector3d(0, 0, 1);

NXOpen.DatumAxis Datum1 = (NXOpen.DatumAxis)workPart.FindObject("Z Axis of Datum Coordinate System(0)");
NXOpen.Positioning.ConstraintReference ConstRef = CompConst.CreateConstraintReference(workPart, Datum1, false, false,false);