Jump to content
lsleepless

How to move/translate Grips in Dynamic Block?

Recommended Posts

lsleepless

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.

Share this post


Link to post
Share on other sites
lsleepless

....I hear echos in here...:ouch:

Share this post


Link to post
Share on other sites
SLW210

Gets slow around the Holidays.

Share this post


Link to post
Share on other sites
lsleepless

Yeah, I guess so.

 

Oh well, I will have to do things the hard way till some one can answer that for me.

Share this post


Link to post
Share on other sites
BlackBox

Couple of things....

 

I am looking for a way to do the equivalent in C#.

 

Err :unsure:?

 

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.

Share this post


Link to post
Share on other sites
lsleepless

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.

Share this post


Link to post
Share on other sites
lsleepless

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?

Share this post


Link to post
Share on other sites
BlackBox

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. :beer:

Share this post


Link to post
Share on other sites
BlackBox
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.

Share this post


Link to post
Share on other sites
BlackBox

Oh (only loosely related), and if you need the Visual LISP ActiveX COM Object Model, you might find this site to be useful.

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...