Inventor is over rotating imported blocks from C# add-in

Inventor is over rotating imported blocks from C# add-in

Anonymous
Not applicable
395 Views
2 Replies
Message 1 of 3

Inventor is over rotating imported blocks from C# add-in

Anonymous
Not applicable

I don't know where else to put this, but, I'm writing an add-on for inventor, and I have a button that imports a block with an arrow.  The block can be at 0, 90, 180, or 270 degrees.

 

When I insert the block like this, however....

TransientGeometry tg = app.TransientGeometry;
dwg.ActiveSheet.AutoCADBlocks.Add(acbd, tg.CreatePoint2d(xLoc, yLoc), (double)md.Orientation, scaleX);

it's behaving...interestingly.

rotation of 0 degrees works.  90 degrees sets it to 116.6, 180 degrees sets it to 233.2, and 270 degrees sets it to 349.9.

 

Why is inventor adding those extra degrees of rotation??? and why does it seem like the number of degrees added is (degrees / 90 * 26.6 <--- why this number????) ??

 

 

here's the full section:

Document blockDefDoc = app.Documents.Open(materialPath, false);

                        if (blockDefDoc.DocumentType == DocumentTypeEnum.kDrawingDocumentObject)
                        {
                            DrawingDocument tedsbomDWG = blockDefDoc as DrawingDocument;
                            AutoCADBlockDefinitions acbds = tedsbomDWG.AutoCADBlockDefinitions;

                            foreach (AutoCADBlockDefinition acbd in acbds)
                            {
                                if (acbd.Name == "material")
                                {
                                    acbd.CopyTo(dwg as _DrawingDocument);
                                }
                            }
                        }
                        blockDefDoc.Close(true);
                        foreach (AutoCADBlockDefinition acbd in dwg.AutoCADBlockDefinitions)
                        {
                            if (acbd.Name == "material")
                            {
                                double scaleY = (dwg.ActiveSheet.Height / 8) / 13;
                                double scaleX = (dwg.ActiveSheet.Width / 8) / 30;

                                if (scaleY < scaleX)
                                {
                                    scaleX = scaleY;
                                }

                                double xLoc = (dwg.ActiveSheet.Width / 2) - (30 / 2 * scaleX);
                                double yLoc = (dwg.ActiveSheet.Height / 2) - (13 / 2 * scaleX);
                                TransientGeometry tg = app.TransientGeometry;
                                dwg.ActiveSheet.AutoCADBlocks.Add(acbd, tg.CreatePoint2d(xLoc, yLoc), (double)md.Orientation, scaleX);
                            }
                        }

 

 

 

0 Likes
Accepted solutions (1)
396 Views
2 Replies
Replies (2)
Message 2 of 3

LukeDavenport
Collaborator
Collaborator
Accepted solution

I imagine the rotation angle is in radians. 

So just multiply your input in degrees by π/180 and you'll be speaking Inventor's language.

Luke

 

Message 3 of 3

Anonymous
Not applicable

hell yeah dude, that fixed it.  thanks man.
the input is a double, so i was kind of wondering if that wasn't the case.

0 Likes