Jump to content

Recommended Posts

Posted

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.

Posted

Yeah, I guess so.

 

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

Posted

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.

Posted

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.

Posted

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?

Posted

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:

Posted
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.

Posted

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

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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