public static void AddSystemVariableSRCHPATH(String valueVariable) { valueVariable = valueVariable.Replace("/", "\\"); foreach (String value in GetSystemVariableSrchPath()) { if (value.IndexOf(valueVariable) > -1) { return; } } String newValueVariable = (string)AcApp.GetSystemVariable("SRCHPATH") + ";" + valueVariable; AcApp.SetSystemVariable("SRCHPATH", newValueVariable); }
public static void Zoom(AcGe.Point3d pMin, AcGe.Point3d pMax, AcGe.Point3d pCenter, double dFactor) { int nCurVport = System.Convert.ToInt32(AcApp.GetSystemVariable("CVPORT")); if (db.TileMode == true) { if (pMin.Equals(new AcGe.Point3d()) == true && pMax.Equals(new AcGe.Point3d()) == true) { pMin = db.Extmin; pMax = db.Extmax; } } else { // Check to see if Paper space is current if (nCurVport == 1) { // Get the extents of Paper space if (pMin.Equals(new AcGe.Point3d()) == true && pMax.Equals(new AcGe.Point3d()) == true) { pMin = db.Pextmin; pMax = db.Pextmax; } } else { // Get the extents of Model space if (pMin.Equals(new AcGe.Point3d()) == true && pMax.Equals(new AcGe.Point3d()) == true) { pMin = db.Extmin; pMax = db.Extmax; } } } using (AcDb.Transaction acTrans = db.TransactionManager.StartTransaction()) { using (AcDb.ViewTableRecord acView = ed.GetCurrentView()) { AcDb.Extents3d eExtents; AcGe.Matrix3d matWCS2DCS; matWCS2DCS = AcGe.Matrix3d.PlaneToWorld(acView.ViewDirection); matWCS2DCS = AcGe.Matrix3d.Displacement(acView.Target - AcGe.Point3d.Origin) * matWCS2DCS; matWCS2DCS = AcGe.Matrix3d.Rotation(-acView.ViewTwist, acView.ViewDirection, acView.Target) * matWCS2DCS; if (pCenter.DistanceTo(AcGe.Point3d.Origin) != 0) { pMin = new AcGe.Point3d(pCenter.X - (acView.Width / 2), pCenter.Y - (acView.Height / 2), 0); pMax = new AcGe.Point3d((acView.Width / 2) + pCenter.X, (acView.Height / 2) + pCenter.Y, 0); } using (AcDb.Line acLine = new AcDb.Line(pMin, pMax)) { eExtents = new AcDb.Extents3d(acLine.Bounds.Value.MinPoint, acLine.Bounds.Value.MaxPoint); } double dViewRatio; dViewRatio = (acView.Width / acView.Height); matWCS2DCS = matWCS2DCS.Inverse(); eExtents.TransformBy(matWCS2DCS); double dWidth; double dHeight; AcGe.Point2d pNewCentPt; if (pCenter.DistanceTo(AcGe.Point3d.Origin) != 0) { dWidth = acView.Width; dHeight = acView.Height; if (dFactor == 0) { pCenter = pCenter.TransformBy(matWCS2DCS); } pNewCentPt = new AcGe.Point2d(pCenter.X, pCenter.Y); } else { dWidth = eExtents.MaxPoint.X - eExtents.MinPoint.X; dHeight = eExtents.MaxPoint.Y - eExtents.MinPoint.Y; pNewCentPt = new AcGe.Point2d(((eExtents.MaxPoint.X + eExtents.MinPoint.X) * 0.5), ((eExtents.MaxPoint.Y + eExtents.MinPoint.Y) * 0.5)); } if (dWidth > (dHeight * dViewRatio)) { dHeight = dWidth / dViewRatio; } if (dFactor != 0) { acView.Height = dHeight * dFactor; acView.Width = dWidth * dFactor; } acView.CenterPoint = pNewCentPt; ed.SetCurrentView(acView); } acTrans.Commit(); } }
public static String GetSystemVariable(String variableName) { return((string)AcApp.GetSystemVariable(variableName)); }