Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding drawing views

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
250 Views, 6 Replies

Adding drawing views

IV 2009, windows XP sp2
I am having difficulty creating new views from a base view, this is the line of code I am a problem with:
Set oDrawView1 = oDoc.ActiveSheet.DrawingViews.AddProjectedView(oAddDrawingView2, oCoord1, kFromBaseDrawingViewStyle)

The error is “Run-time error ‘5’: Invalid procedure call or argument.”

It has something to do with the size of the view, if I scale the view larger it works OK.
It is the size and not the scale because other larger views with the same scale work OK.

I have tried checking the area of the view borders to see if there is any relationship, but I can’t find any similarity among the views and the size that they stop working? I have tried a number of parts and view sizes.

The work around at present is to change the scale of the view create the other views and change the scale back, however a permanent solution would be helpful.

Regards Malcolm
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

I've not heard of any problems like this before. Can you provide a test
case that demonstrates it?
--
Brian Ekins
Autodesk Inventor API
Message 3 of 7
Anonymous
in reply to: Anonymous

Hi Brian
The attached zip file should show the problem.

Open the drawing, run the macro and click on the view. If it works the same for you it will error.

Change the view scale to 1:1 and try again and it will add a plan view.

Regard Malcolm
Message 4 of 7
Anonymous
in reply to: Anonymous

I get an error but without the source code can't do anything to determine
why. Can you send me an unprotected VBA project or a simpler example that
also demonstrates the problem? If you want to keep the source confidential
you can email it directly to me at brian.ekins@autodesk.com
--
Brian Ekins
Autodesk Inventor API
Message 5 of 7
Anonymous
in reply to: Anonymous

I was sure I removed the password, but here it is again.

Malcolm
Message 6 of 7
Anonymous
in reply to: Anonymous

I found the problem. It turns out there is a limitation in the
AddProjectedView method. The point to position the new view needs to be
outside of the existing view. This is almost always the case so it explains
why it hasn't been reported before. If you change your current line

Set oCoord2 = oTransGeom.CreatePoint2d(PositionX, PositionY +
(((NewHeight + ViewHeight) / 2) + 3))
to
Set oCoord2 = oTransGeom.CreatePoint2d(PositionX, PositionY +
ViewHeight)

it will work. The important thing is to be at least as far as the height of
the existing view. If for some reason you need the view closer than than
you can still create it further away and then move it back to the close
position.

The scale of the view doesn't really matter except that in your code with
was causing the offset to change and once the scale was big enough it ended
up with an offset distance that would work.
--
Brian Ekins
Autodesk Inventor API
Message 7 of 7
Anonymous
in reply to: Anonymous

Thanks Brian I can see where I went wrong now.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report