Author Topic: ( C3D ) "Zoom To Point" command  (Read 2612 times)

0 Members and 1 Guest are viewing this topic.

sinc

  • Guest
( C3D ) "Zoom To Point" command
« on: April 09, 2007, 11:20:25 pm »
I finally got tired of hunting for points in Prospector in order to zoom to them, so here's a routine that lets you type the point number at the command line.  There doesn't seem to be any way to do this via .NET, so I use the COM object.  (I think I'm finally getting the hang of using a crippled .NET API...  :wink:)

Full source code and DLL compiled for 2007 in the usual place.

Code: [Select]
[CommandMethod("ZOOMPT")]
public void ZoomToPointCommand()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptIntegerOptions intOps = new PromptIntegerOptions("\nZoom to point: ");
intOps.AllowNegative = false;
intOps.AllowZero = false;
intOps.AllowNone = true;
intOps.AllowArbitraryInput = false;
PromptIntegerResult intRes = ed.GetInteger(intOps);
if (intRes.Status.Equals(PromptStatus.OK)) {
try {
C3DUtil c3dUtil = new C3DUtil();
AeccPoint pt = c3dUtil.AeccDb.Points.Find(intRes.Value);
Database db = Application.DocumentManager.MdiActiveDocument.Database;
db.TileMode = true;
AeccSettingsDrawing drSettings = c3dUtil.AeccDb.Settings.DrawingSettings;
AcadApplication pApp = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
pApp.ZoomCenter(pt.Location, 4*drSettings.UnitZoneSettings.DrawingScale);
}
catch {
ed.WriteMessage("\nPoint {0} not found.", intRes.Value);
}
}
}

Mark

  • Custom Title
  • Administrator
  • Seagull
  • Posts: 28155
Re: ( C3D ) "Zoom To Point" command
« Reply #1 on: April 10, 2007, 09:55:54 am »
Thanks a bunch sinc!
TheSwamp.org  (serving the CAD community since 2003)

Jeff_M

  • King Gator
  • Posts: 3899
  • C3D user & customizer
Re: ( C3D ) "Zoom To Point" command
« Reply #2 on: April 10, 2007, 01:48:40 pm »
Nice work, Sinc. I had done a similar thing in lisp a few months ago. The beauty of lisp is that I can use the same program in different versions. So far, we need to recompile the C# code for each version. This has been tested in C3D2007 & C3D2008

I did modify the Zoom scale based on your 4*DrawingScale idea. I had used a 10% of the current viewsize which worked great when zoomed to extents, but sucked when already zoomed in.....
Code: [Select]
(defun c:zoom2pt (/ aeccdoc appstr point points pt pt# vrsn)
  (vl-load-com)
  (setq vrsn (vlax-product-key))
  (cond ((vl-string-search "R16.2" vrsn)(setq appstr "3.0"));;2006
((vl-string-search "R17.0" vrsn)(setq appstr "4.0"));;2007
        ((vl-string-search "R17.1" vrsn)(setq appstr "5.0"));;2008
(t (alert "This version of C3D not supported!"))
)
  (if (and appstr
   (or *acad*
       (setq *acad* (vlax-get-acad-object))
       )
   (or *AeccApp*
       (setq *AeccApp* (vla-getinterfaceobject *acad*
(strcat "AeccXUiLand.AeccApplication." appstr)))
       )
   (setq aeccdoc (vlax-get *AeccApp* 'ActiveDocument))
   (setq pt# (getint "\nZoom to point #?: "))
   (setq points (vlax-get aeccdoc 'points))
   (not (vl-catch-all-error-p
  (vl-catch-all-apply
    '(lambda ()
       (setq point (vlax-invoke points 'find pt#))
       )
    )
  )
)
   )
    (progn
      (setq pt (vlax-get point 'location))
      (vlax-invoke *acad* 'zoomcenter pt (* 4.0
    (vlax-get
      (vlax-get
(vlax-get
  (vlax-get aeccdoc 'settings)
  'drawingsettings)
'unitzonesettings)
      'drawingscale)
    )
)
      (vlax-release-object points)
      (vlax-release-object aeccdoc)
      )
    )
  (princ)
  )

sinc

  • Guest
Re: ( C3D ) "Zoom To Point" command
« Reply #3 on: April 10, 2007, 04:41:16 pm »
Did you ever do any poking around with late binding, to see if it's possible to get one DLL that will work in multiple versions?  That's something I'm planning on looking at once I have 2008.

At the moment, it might not be too much of an issue.  C3D is changing so fast that I can't see staying on ANY version once a new one is out, unlike what people do with the other versions.  That's the main reason why I suspect it won't be a big issue if they don't release a patch for the Curve class API, because it seems like an actively bad idea to stay on old versions of Civil-3D.

Jeff_M

  • King Gator
  • Posts: 3899
  • C3D user & customizer
Re: ( C3D ) "Zoom To Point" command
« Reply #4 on: April 10, 2007, 05:00:57 pm »
Did you ever do any poking around with late binding <snip>
I just looked around the Adesk .NET newsgroup and there wasn't much to see, 3 posts IIRC.

I would tend to agree with you that it makes no sense to not move to the next release.....but there are still folks asking questions about C3D2006, so SOMEONE likes to hang back a version or two.