Inventor Customization

Reply
Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 81 of 121 (3,939 Views)

Re: iLogic Coding to Create Automated Drawing

04-13-2012 08:47 AM in reply to: mehatfie

All,

 

Attached you'll find the FULL DRAWING CODE as well as a photo of what this code produces.

 *This code was created in run directly in iLogic

 

I have Fully commented it to make it easier to understand and have created what is probably a page of comments at the top of the code describing how to use each Function.

 

This is on and off research throughout 2 months of searching through threads and finding different codes to learn from.

 

Except now it's ALL IN ONE PLACE on this thread!!!

 

Keep in mind that my code is run through an assembly which is also fully parameter based and runs on multiple iLogic rules. This is why all of my dimensions are Names as they are parameters being passed into the sub.

 

The code places all of the views at a single point when they are created. These views are then moved based on a code in the Drawing Template. This code is not complete but I have attached the one I use right now for reference. Also keep in mind that Parameters are used here which is why you might see names where numbers or Letters should be.

 

I hope this helps you while your learning the code and API. Here are some other threads I used:

 

http://forums.autodesk.com/t5/forums/forumtopicprintpage/board-id/120/message-id/37402/print-single-...

 

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/dimension-sheet-metal-drawing/td-p/183...

 

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Add-Centerlines-through-VBA/td-p/30897...

 

http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/Drawing-Automation-with-VBA/td-p/29835...

 

http://forums.autodesk.com/autodesk/attachments/autodesk/78/410518/2/viewcolor.txt

 

 

 

Please feel free to ask any questions while I am still available

Kudo's if this helps you!

 

Thanks for all Your Help!

Mitch

 

Mentor
MegaJerk
Posts: 249
Registered: ‎01-26-2011
Message 82 of 121 (3,928 Views)

Re: iLogic Coding to Create Automated Drawing

04-13-2012 09:36 AM in reply to: mehatfie

This is really awesome! Thanks a lot of sharing your finished product, as it should come in handy for pushing automation to higher (sexier) levels. It's a wonderful thing to see this all come together (more so for you I'm sure!). 

Congrats!  

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, -
as it increases my power levels and will eventually help to elevate me towards outer space.

Check out my iLogic injection tool here : http://goo.gl/ce1Qg
--------------------------------------------------------------------------------------
Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 83 of 121 (3,871 Views)

Re: iLogic Coding to Create Automated Drawing

04-17-2012 10:24 AM in reply to: MegaJerk

I'm going to post a revision of the code as I've added a few more subs for ordinate dimensions and centerlines as well as changed a few things.

 

But first I have a question, if you see the attached photos, I am trying to place a Hole Thread Note.

 

I've tried using different intent points or just the drawing curve while adding the note, but I always end up getting the "Wrong" note as the leader is on the other side of the circle

 

Thanks

Mitch

New Member
Posts: 2
Registered: ‎05-09-2012
Message 84 of 121 (3,688 Views)

Re: iLogic Coding to Create Automated Drawing

05-09-2012 11:19 AM in reply to: mehatfie

I am using an ilogic rule to make center lines with an event trigger (before saving document)

 

ActiveSheet.View("VIEW1").View.SetAutomatedCenterlineSettings()
On Error Resume Next

 

ActiveSheet.View("VIEW2").View.SetAutomatedCenterlineSettings()
On Error Resume Next

ActiveSheet.View("VIEW3").View.SetAutomatedCenterlineSettings()
On Error Resume Next

 

Is there a better way to do this?  The obvious problem is if theres is au 4th view...

Also, because of automated centerlines default settings, the only centerlines beeing drawn are the one where you see a hole function as a circle.  No center lines are being drawn on cylindcrical shapes or patterns,

Is there a way to set the automated centerlines options so that they remain a certain way and not always revert to only drawing center lines on a hole top view?

 

Thank you

Louis G

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 85 of 121 (3,663 Views)

Re: iLogic Coding to Create Automated Drawing

05-10-2012 07:46 PM in reply to: LouisGuillemette

Hi Louis,

 

Unfortunately I currently do not have access to Inventor to fully assist you, but the following code should be something like what you're looking for. A few minor tweeks might be needed.

 

For the centerline settings, there is a way to change this programmically with the API, but as I said, I do not currently have access to Inventor.

 

>>> If you are using a template drawing, you can set the default Automated Centerlines but accessing "Document Settings" under the "Manage" tab. I do not remember how to direct you farther from here, but once you set up the centerline's default options, these centerlines will always be placed whenever you run "SetAutomatedCenterlineSettings"

 

Cheers

Mitch

 

'		Dim oNumView As DrawingView
'		Dim ViewCount As Integer
'		Dim StartCount As Integer
'		
'		ViewCount = 0
'		StartCount = 0
'////////////////////////////////   Counts the number of drawing views on the sheet
'		For Each oNumView In ActiveSheet.DrawingViews
'			ViewCount = ViewCount + 1
'		Next
'//////////////////////////////////// Places Centerlines on all of the drawing views
'		For StartCount = 1 To ViewCount
'			ActiveSheet.DrawingViews(StartCount).SetAutomatedCenterlineSettings()
'		Next
 
*Expert Elite*
mrattray
Posts: 2,240
Registered: ‎09-13-2011
Message 86 of 121 (3,657 Views)

Re: iLogic Coding to Create Automated Drawing

05-11-2012 05:12 AM in reply to: mehatfie

Just out of curiosity, why do you do it with two loops? Why not just set the centerlines in the for each loop?

Also, if you change the names of your views from default or if you delete views I think the code will fail. It will look for view 4 which no longer exists due to either now being view c or becuase it was deleted and return an error.

 

I think this will work better, although I'm much too lazy today to test it.

 

dim oview as drawingview
dim oviews as drawingviews

views = activesheet.drawingviews

for each oview in oviews
ActiveSheet.DrawingViews(oview.name).SetAutomatedCenterlineSettings()
next

 

Mike (not Matt) Rattray

New Member
Posts: 2
Registered: ‎05-09-2012
Message 87 of 121 (3,647 Views)

Re: iLogic Coding to Create Automated Drawing

05-11-2012 11:45 AM in reply to: mehatfie

Hi

It finally works!

Thank you all for your help.

 

Here is the code:


Public Sub LignesAxes()

Dim oNumView As DrawingView
Dim ViewCount As Integer
Dim StartCount As Integer
Dim oview As DrawingView

StartCount = 0

'number of drawing views
ViewCount = ThisApplication.ActiveDocument.ActiveSheet.DrawingViews.Count

'define collection of views objects
Set oviews = ThisApplication.ActiveDocument.ActiveSheet.DrawingViews

' Places Centerlines on all of the drawing views
      For StartCount = 1 To ViewCount
           oviews.Item(StartCount).SetAutomatedCenterlineSettings
       Next
End Sub

 

 

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 88 of 121 (3,376 Views)

Re: iLogic Coding to Create Automated Drawing

06-22-2012 11:07 AM in reply to: mrattray

Hi mrattray,

 

I initially used a single loop to do a lot of my tasks, but for some reason the program would fail as it would not search correctly through every single object. By doing it this way with 2 loops, I am telling the program to access that specific object through it's index and perform the neccessary tasks.

 

I believe you're also talking about the function, where I have the filler views as parameters. You are right that the program will not work if these are removed. These are just place holders as all parameters that consist in the function need to be filled in for the program to run. A previous parameter in that same function tells it what views to use, and the rest of the filler views are not taken into account.

 

Sorry for the long delay

 

Mitch

Contributor
Posts: 13
Registered: ‎09-03-2012
Message 89 of 121 (2,901 Views)

Re: iLogic Coding to Create Automated Drawing

09-04-2012 01:45 AM in reply to: mehatfie

Hello,

 

              Your codes are really awsome. Could you attach the inventor assembly file releated to this code. Its very helpful for me.

 

BR.

Karthick

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 90 of 121 (2,879 Views)

Re: iLogic Coding to Create Automated Drawing

09-04-2012 06:56 AM in reply to: karram

Hi Karthick,

 

Unfortunately I cannot provide you with the files themselves do to company policies, but can assist you with any further questions you may have.

 

I may be able to provide screenshots as well for specific scenarios

 

Thanks

Mitch

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube