lsleepless Posted December 19, 2012 Posted December 19, 2012 I have been trying to figure this out for the past couple of days with no luck. In the editor I am able to select a polar grip from a dynamic block and place it where needed, it updates stretch and angle for custom properties on the dynamic block. I am looking for a way to do the equivalent in C#. This is what I have tried so far public void MoveGrip(Point3d gripPoint, Vector3d offset) { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Transaction tr = db.TransactionManager.StartTransaction(); using (tr) { BlockReference br = null; Entity ent = (Entity)tr.GetObject(_oBlockRefId, OpenMode.ForWrite); br = ent as BlockReference; if(br != null) { GripDataCollection grips = new GripDataCollection(); GripDataCollection updateGrip = new GripDataCollection(); double curViewUnitSize = 0; int gripSize = 0; Vector3d curViewDir = doc.Editor.GetCurrentView().ViewDirection; GetGripPointsFlags bitFlags = GetGripPointsFlags.GripPointsOnly; br.GetGripPoints(grips, curViewUnitSize, gripSize, curViewDir, bitFlags); foreach (GripData grip in grips) { if (grip.GripPoint == gripPoint) { updateGrip.Add(grip); } } br.MoveGripPointsAt(updateGrip, offset, MoveGripPointsFlags.Polar); } } } It does collect points, and match with the point passed in(as I know know other way to specify what point I want to move). But when it tries to execute MoveGripPoibtsAt nothing is changed, and no exceptions are thrown that I am aware of. I have also spent a couple of days trying to find documentation for this, with no luck. Where the hell is the api documentation for autocad 2013? I keep finding stuff for civil and others, but nothing for autocad. This is immensely frustrating. Quote
lsleepless Posted December 20, 2012 Author Posted December 20, 2012 ....I hear echos in here... Quote
lsleepless Posted December 20, 2012 Author Posted December 20, 2012 Yeah, I guess so. Oh well, I will have to do things the hard way till some one can answer that for me. Quote
BlackBox Posted December 20, 2012 Posted December 20, 2012 Couple of things.... I am looking for a way to do the equivalent in C#. Err ? You posted C#... Are you meaning to suggest that you have working VB.NET code? If so, post it, so others can help you properly translate. This is what I have tried so far public void MoveGrip(Point3d [color=blue]gripPoint[/color], Vector3d [color=blue]offset[/color]) { Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Database db = doc.Database; Transaction tr = db.TransactionManager.StartTransaction(); using (tr) { BlockReference br = null; Entity ent = (Entity)tr.GetObject([color=red]_oBlockRefId[/color], OpenMode.ForWrite); br = ent as BlockReference; if(br != null) { GripDataCollection grips = new GripDataCollection(); GripDataCollection updateGrip = new GripDataCollection(); double curViewUnitSize = 0; int gripSize = 0; Vector3d curViewDir = doc.Editor.GetCurrentView().ViewDirection; GetGripPointsFlags bitFlags = GetGripPointsFlags.GripPointsOnly; br.GetGripPoints(grips, curViewUnitSize, gripSize, curViewDir, bitFlags); foreach (GripData grip in grips) { if (grip.GripPoint == gripPoint) { updateGrip.Add(grip); } } br.MoveGripPointsAt(updateGrip, offset, MoveGripPointsFlags.Polar); } } } It does collect points, and match with the point passed in(as I know know other way to specify what point I want to move). But when it tries to execute MoveGripPoibtsAt nothing is changed, and no exceptions are thrown that I am aware of. Your posted code contains an error: The name '_oBlockRefId' does not exist in the current context ... Perhaps you posted incomplete code? Is this defined elsewhere as a Property or Field, or even as a variable in the calling Method's scope? I have also spent a couple of days trying to find documentation for this, with no luck. Where the hell is the api documentation for autocad 2013? I keep finding stuff for civil and others, but nothing for autocad. This is immensely frustrating. Kerry was kind enough to post a link for The online AutoCAD 2013 .NET Developers Guide in this post. Quote
lsleepless Posted December 20, 2012 Author Posted December 20, 2012 Sorry for the confusion, I do not have working code in VB. I just prefer C# over VB. _oBlockRefId is just a reference to the ID of the dynamic block I am trying to modify parameters for. The method is part of an extension class used to facilitate working with dynamic blocks. Thanks so much for the link to the API documentation, not sure why I was having such a hard time finding it!. If I figure something out I will definitely share. Quote
lsleepless Posted December 20, 2012 Author Posted December 20, 2012 Actually with the link, I dont actually see the complete documentation for the API. I see the overview and components that mentions the dlls used. I guess what I am really looking for is a reference document, is there anything like that out there, or am I just overlooking it in the help doc? Quote
BlackBox Posted December 20, 2012 Posted December 20, 2012 Thanks so much for the link to the API documentation, not sure why I was having such a hard time finding it!. No worries; I'm happy to help. Quote
BlackBox Posted December 20, 2012 Posted December 20, 2012 Actually with the link, I dont actually see the complete documentation for the API. I see the overview and components that mentions the dlls used. I guess what I am really looking for is a reference document, is there anything like that out there, or am I just overlooking it in the help doc? The online help has always been bad, but 2013 is infamously worse... The best work around AFAIK, is to download offline help instead. Quote
BlackBox Posted December 20, 2012 Posted December 20, 2012 Oh (only loosely related), and if you need the Visual LISP ActiveX COM Object Model, you might find this site to be useful. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.