public void CreateHideWire(XYZ po, Line wireline, WireType type, WiringType wiringtype, View view, double halfdis /*mm*/) { var doc = type.Document; var pointonLine = po.ProjectToXLine(wireline); var dir = wireline.Direction.CrossProduct(XYZ.BasisZ).Normalize();//(pointonLine - po).Normalize(); var point1 = pointonLine + dir * halfdis / 304.8; var point2 = pointonLine - dir * halfdis / 304.8; //MessageBox.Show(dir.ToString() + Environment.NewLine + // point1.ToString() + Environment.NewLine + // point2.ToString()); var polist = new List <XYZ>(); polist.Add(point1); polist.Add(point2); Wire.Create(doc, type.Id, view.Id, wiringtype, polist, null, null); }
/// <summary> /// Initializes a new instance of the <see cref="DevicePattern"/> class. /// </summary> /// <param name="wiringType"> /// The wiring type. /// </param> public DevicePattern(WiringType wiringType) { this.WiringType = wiringType.ToString(); this.LinkCount = null; this.LinkState = null; }
public void CreateHideWire(FamilyInstance ins, Line wireLine, WireType type, WiringType wiringtype, View view) { var doc = ins.Document; var locationpo = (ins.Location as LocationPoint).Point; var linedir = wireLine.Direction; if (IsLocationInCenter(ins)) { var facingDir = ins.FacingOrientation; var handDir = ins.HandOrientation; var viewscale = view.Scale; var lengthRatio = viewscale / 50.0; var width = lengthRatio * getWidth(ins); var height = lengthRatio * getHeight(ins); var po1 = default(XYZ); // locationpo + height / 4 * handDir; var po2 = default(XYZ); //locationpo - height / 4 * handDir; if (linedir.AngleTo(handDir) < Math.PI / 4) { po1 = locationpo + width / 4 * handDir; po2 = locationpo - width / 4 * handDir; } else { po1 = locationpo + height / 4 * facingDir; po2 = locationpo - height / 4 * facingDir; } var polist = new List <XYZ>(); polist.Add(po1); polist.Add(locationpo); polist.Add(po2); //Wire.Create(doc, type.Id, view.Id, wiringtype,, null, null); doc.Invoke(m => { foreach (var po in polist) { CreateHideWire(po, wireLine, type, wiringtype, view, 3); } }, "tem"); } if (IslocationNearBottom(ins)) { var facingDir = ins.FacingOrientation; var handDir = ins.HandOrientation; var viewscale = view.Scale; var lengthRatio = viewscale / 50.0; var width = lengthRatio * getWidth(ins); var height = lengthRatio * getHeight(ins); var po1 = default(XYZ); // locationpo + height / 4 * handDir; var po2 = default(XYZ); //locationpo - height / 4 * handDir; if (linedir.AngleTo(handDir) < Math.PI / 4) { po1 = locationpo + width / 4.0 * handDir; po2 = locationpo - width / 4.0 * handDir; } else { po1 = locationpo + height / 4 * facingDir; po2 = po1 + height / 4 * facingDir; } var polist = new List <XYZ>(); polist.Add(po1); polist.Add(locationpo); polist.Add(po2); //Wire.Create(doc, type.Id, view.Id, wiringtype,, null, null); doc.Invoke(m => { foreach (var po in polist) { CreateHideWire(po, wireLine, type, wiringtype, view, 3); } }, "tem"); } else { var facingDir = ins.FacingOrientation; var handDir = ins.HandOrientation; var viewscale = view.Scale; var lengthRatio = viewscale / 50.0; var width = lengthRatio * getWidth(ins); var height = lengthRatio * getHeight(ins); var po1 = default(XYZ); // locationpo + height / 4 * handDir; var po2 = default(XYZ); //locationpo - height / 4 * handDir; if (linedir.AngleTo(handDir) < Math.PI / 4) { po1 = locationpo + width / 4 * handDir; po2 = locationpo - width / 4 * handDir; } else { po1 = locationpo + height / 4 * facingDir; po2 = locationpo - height / 4 * facingDir; } var polist = new List <XYZ>(); polist.Add(po1); polist.Add(locationpo); polist.Add(po2); //Wire.Create(doc, type.Id, view.Id, wiringtype,, null, null); doc.Invoke(m => { foreach (var po in polist) { CreateHideWire(po, wireLine, type, wiringtype, view, 3); } }, "tem"); } }