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: 

iLogic Coding to Create Automated Drawing

132 REPLIES 132
SOLVED
Reply
Message 1 of 133
mehatfie
44519 Views, 132 Replies

iLogic Coding to Create Automated Drawing

Hi all,

I'm attempting to create a model that autmotaically derives ready-to-go drawings. I've gotten pretty far in doing so but have a few issues with regards to dimensioning. As I'm sure you're aware, when the model changes, a dimension to that feature, which has been removed, is also deleted and some those dimensions do not return once the model is changed back.

I have looked into using different view representations, but have found that they do not accommodate feature supression.

My questions are:

Is there a way to program in the dimensioning of a view

Create center points for of of the holes and center lines

And for a feature note such as "Hole and Thread" dimensioning, when the model expands, the leader and text length do not change and proceed into the view. Is there a way to fix or anchor the text to a certain spot on the drawing, and have the leader length expand and change accordingly to that point.

If you would like farther information, or think a similar question would help, please ask. Thanks in advance for any help.

Mitch

132 REPLIES 132
Message 2 of 133
mehatfie
in reply to: mehatfie

Also, If there is anyway to anchor the linear dimensions as well or set an offset from the attached view. When the model changes, the dimension is either absorbed into the view or becomes to far away.

 

Thanks Again

Mitch

Message 3 of 133
MjDeck
in reply to: mehatfie

Are you using derived parts?  If you can avoid using derived parts, then dimensions on suppressed features should come back when you unsuppress the features.
 If you are deriving only parameters but no geometry, you can use the Link button in the Parameters dialog instead of the Derive command.


Mike Deck
Software Developer
Autodesk, Inc.

Message 4 of 133
mehatfie
in reply to: MjDeck

Hi Mike,

 

For some reason when I previously tried dimensioning suppressed features, suppressing them,  then unsuppressing them, some dimensions would disappear. I decided to try it again yesterday and it worked!

 

The issue I'm now having in regards to the linear dimensions or feature dimensioning is how they get ingulfed in the view when the model becomes larger. Is there a way to move the dimensions to a fixed point on the drawing, or always have them a certain distance from the view so that when the model size changes the dimension does not move inside the view or extremly far a way.

 

Thanks

Mitch

Message 5 of 133
MjDeck
in reply to: mehatfie

Using the API, it should be possible to move dimensions based on changes in the model.  For a particular model, you could probably hard-code some simple rules for dimension locations.  But in general it's a complicated problem.  Sorry, I don't have a sample or suggestions.


Mike Deck
Software Developer
Autodesk, Inc.

Message 6 of 133
mrattray
in reply to: MjDeck

I'm working on the very same problems.  If you don't mind, I'd like to swap models/drawings with you and take a look at your workflow.  There doesn't seem to be very many people out there doing this sort of thing.

Mike (not Matt) Rattray

Message 7 of 133
mehatfie
in reply to: mrattray

Thank you Mike Deck for your Assistance.

 

mrattray, I have replied to you on your own post after reading through your situation as well

 

Mitch

Message 8 of 133
mehatfie
in reply to: mehatfie

I now am trying to Create a Drawing from the assembly and I have the following code:

 

Format:HTML Format Version:1.0 StartHTML:     165 EndHTML:   13682 StartFragment:     314 EndFragment:   13650 StartSelection: 314 EndSelection:     314
SyntaxEditor Code Snippet

ImportsInventor.ViewOrientationTypeEnumImportsInventor.DrawingViewStyleEnum
DimoDrawingDocasDrawingDocumentDimoPartDocasDocumentDimoSheetAssheetDimoTGAsTransientGeometryDimoView1asDrawingViewDimoView2asDrawingViewDimoView3asDrawingViewDimoView4asDrawingView
ViewScale=3/16
'Ask to create drawing?dwgQuery=MsgBox("Would you like to Create a drawing for this MODEL?", vbYesNo,"Drawing Selection")IfdwgQuery=vbYesThenoPartDoc=ThisDoc.Document'Define IDW Template File LocationoDrawingDoc=ThisApplication.Add.kDrawingDocument("C:\Vault_Work\PROJECTS\iLogic Parts-inprogress\iLogic Part Generators\Rectangular Transition Chute Generator\Template.idw", True)oSheet=oDrawingDoc.Sheets.Item(1)'Define 2d view bottom left corner points for four viewsoPoint1=ThisApplication.TransientGeometry.CreatePoint2d(1, 1)oPoint2=ThisApplication.TransientGeometry.CreatePoint2d(1, 6)oPoint3=ThisApplication.TransientGeometry.CreatePoint2d(5, 1)oBaseView=oSheet.DrawingViews.AddBaseView(oPartDoc,oPoint1, 3/16,kFrontViewOrientation, kHiddenLineDrawingViewStyle)', KTANGENTEDGESON)oView2=oSheet.DrawingView.AddProjectedView(oBaseView,oPoint2, kHiddenLine?DrawingViewStyle, 3/16)oView3=oSheet.DrawingView.AddProjectedView(oBaseView,oPoint3, kHiddenLineDr?awingViewStyle, 3/16)
EndIf

 

 ^ (It seems as though the code will not copy proporly, please advise if you need further explaination)*

 

At lines 29 and 30, I am getting an error message stating the following: "Comma,')', or a valid expression continuation expected"

 

 

As well, I would like to add the following options to the view but I'm unsure where I would put the coding. To what I believe, I simply add a comma and enter the command inside the bracket for the view.

 

I wish to set:

 

View Representation = "Default"

Level of Detail = "MASTER iLogic Assembly"

Line Style = "As Parts"

Hidden Line Calculation = "All Bodies"

 

 

 

Thanks for your Help

Mitch

Message 9 of 133
MjDeck
in reply to: mehatfie

Mitch,
 The format of your code was lost in the process of pasting it to this forum.  Can you copy the rule text into Notepad, save it as a text file, and attach the text file on this forum?  That's a good way to preserve the text.


Mike Deck
Software Developer
Autodesk, Inc.

Message 10 of 133
mrattray
in reply to: mehatfie

The error is with your formatting, so we really need to see how your code is formatted in order to help.

Mike (not Matt) Rattray

Message 11 of 133
mehatfie
in reply to: MjDeck

Sorry, I had posted the attachment 30min ago but for some reason it didn't go through

 

Thanks

Mitch

Message 12 of 133
mrattray
in reply to: mehatfie

oDrawingDoc = ThisApplication.Add.kDrawingDocument("C:\Vault_Work\PROJECTS\iLogic Parts-inprogress\iLogic Part Generators\Rectangular Transition Chute Generator\Template.idw", True)

This isn't correct. You can't call an enumerator as a method. kDrawingDocument is an enumerator.

 

Try this:

 

oDrawingDoc = ThisApplication.Documents.Add("C:\Vault_Work\PROJECTS\iLogic Parts-inprogress\iLogic Part Generators\Rectangular Transition Chute Generator\Template.idw", True)

You don't have to include the enum (kDrawingDocument) because you already declared oDrawingDoc as a DrawingDocument.

 

Disclaimer: I might be completely wrong and not know what I'm tlaking baout.

Mike (not Matt) Rattray

Message 13 of 133
MjDeck
in reply to: mrattray

There's a few more errors.  Here's a modified version of your code that should work.
It's hard to develop new API code in iLogic.  A good approach is to create it in VBA (or even an external VB.NET program) first and then convert it to iLogic.


Mike Deck
Software Developer
Autodesk, Inc.

Message 14 of 133
mehatfie
in reply to: mrattray

Don't worry, I won't hold anything against you for the Disclamier

 

Your Correction Made the code highlighted, which I assume means that it is formatted better. But this change did not add or remove any errors.

 

Mitch

Message 15 of 133
mehatfie
in reply to: MjDeck

Hi Mike,

 

I found the bulk of this code provided by another user and modified it to fit my needs so far, although it still needs a bit of work.

 

I believe you've made changes to the oView2 and oView3 lines, as when I past your lines in, and comment mine out it works..... But I've closley looked at the 2 lines and don't notice any difference besides the "s" in DrawingViews..... This confuses me, as when I place the "s" into my code and use my original lines, the code does not work. Am I missing a change?

 

As well, back to my original question regarding the various options of the view I wish to select. I'm assuming I simply add the correct "enum" inside the bracket.

 

Thanks for your help

Mitch

Message 16 of 133
MjDeck
in reply to: mehatfie

Mitch,

 Here's another error in your original code:
oView2=oSheet.DrawingView.AddProjectedView(oBaseView,oPoint2, kHiddenLine?DrawingViewStyle, 3/16)
oView3=oSheet.DrawingView.AddProjectedView(oBaseView,oPoint3, kHiddenLineDr?awingViewStyle, 3/16)
Notice the question mark characters embedded in the enum constant names.  Those were probably introduced by copying and pasting to or from this forum.  I recommend posting code in text files.
If you do have to copy code from this forum, paste it first Notepad.  Invalid characters should show up as ?


Can you restate your original question about view options?  I did a quick scan of this thread, but I'm not sure what it is.


Mike Deck
Software Developer
Autodesk, Inc.

Message 17 of 133
mrattray
in reply to: MjDeck

There's a very big difference between a plural and singular object. When something is plural (such as DrawingViews) it referes to what's called a collection object which is in this example every view on the sheet or in the drawing. When something is singular (such as DrawingView) it refers to a specific view on a specific sheet.

 

Coding is very very touchy. Everything is case sensitive and any little typo or omission will cause it to fail. This is why Mike recommended writing code in the API or in visual studio, becuase you get better error correcting.

 

You should also get in the habit of using the object browser accessible through IV's API. iLogic follows a very similar object model and for the most part the methods and objects match up between the two.

Mike (not Matt) Rattray

Message 18 of 133
mehatfie
in reply to: mrattray

I have looked through the Object Browser and made a few things work by following it's steps but I'm still getting used to it.

 

Here are the options I wish to set while placing the view Mike:

 

.......................

As well, I would like to add the following options to the view but I'm unsure where I would put the coding. To what I believe, I simply add a comma and enter the command inside the bracket for the view.

 

I wish to set:

 

View Representation = "Default"

Level of Detail = "MASTER iLogic Assembly"

Line Style = "As Parts"

Hidden Line Calculation = "All Bodies"

........................

 

Thanks

Mitch

 

Message 19 of 133
mrattray
in reply to: mehatfie

This is the obkect browser entry for AddProjectedView. You can't add any additional arguments (options) beyond what is indicated. You're currently using every argument that AddProjectedView can take. So, in layman's terms: it's not that easy.  Hopefully, now that I did the easy part and told you what you can't do, Mike can chime in and tell you what you can do. I don't have any experience with creating views.

 

Function AddProjectedView(ParentView As DrawingView, Position As Point2d, ViewStyle As DrawingViewStyleEnum, [Scale]) As DrawingView
    Member of Inventor.DrawingViews
    Creates a projected drawing view

 

 

 

Mike (not Matt) Rattray

Message 20 of 133
mehatfie
in reply to: mrattray

Yes, I noticed that message:

 

Function AddProjectedView(ParentView As DrawingView, Position As Point2d, ViewStyle As DrawingViewStyleEnum, [Scale]) As DrawingView    

     Member of Inventor.DrawingViews    

     Creates a projected drawing view

 

When I was fiddling around and trying to make the code work. Only reason I had suggested inside the brackets is do the the original copying of the code. The original user had left something like this....

 

......AddProjectedView(DrawingView, Point2d, DrawingViewStyleEnum, [Scale])  ', KTANGENTEDGESON) 

 

With the ending enum commented out, so I assumed this meant you could add the enum inside the bracket if you wish to do so

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

Post to forums  

Autodesk Design & Make Report