yes, this may help. I will try this tomorrow in the office.
can you please recommend me the best, shortest, easiest way to learn how to make macros and rules. They are quite the same thing, no?
If you're looking to start with iLogic (which I think is a good place to start) you can use these tutorials:
And here are some examples:
If you're looking to work with VBA and Inventor's Application Programing Interface (API), here are a couple of links that should get you started:
... the paper below provides a brief overview of Inventor’s programming interface and illustrates this with examples using iProperties.
|VBA & Inventor API Introduction (zip - 547Kb)|
The following resource will help you get started with programming Inventor. It assumes familiarity with Autodesk Inventor and general programming concepts.
Check out the Self-Paced Guide “My First Plug-in” presented by the ADN Inventor Team
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
There is one solution using API code to manage the drawing curves within every component in layer.
For example, there are three components in assebmly and create drawing view, this solution will create three layers in style editor for these three components respectively, and the drawing curves in each view projected from the component will be managed in the layer, and the layer's name is the same with the name of component.
Please copy the code in attached text, and paste it in VBA editor within one new drawing, then save it as one template. When the assembly is done, please create drawing views using this template. When the drawing views are done, please run the Macro and you will see the several layers created in style editor. So you can change the color of layer to change the color of drawing curves, which will keep the parts in all the views colored with the same color.
please see the attached image for more details.
Unfortunately both scripts don't work properly... Not all the edges are colored (in case of first script) or included in the new layers (in case of the second script). I noticed these edges are tangent edges of the revolution features. In the attachment you can see the screenshot and you will understand. That is a part in the assembly. Any solution?
I have seen the attached image, and got the issue you show. This Macro does work fine on R2011, and looks that you are using R2012 now. If yes, this is a known issue, and is not reproducible on R2012 SP1 internal build.
When SP1 is released, please have it packaged for a try.
yes, I'm using R2012 and there is little chance that I will have SP1 update...
What a shame!
SP1 fixed the problem!
Brian Ekins' code uses the following line to set each collected edge to a colored layer:
Call drawView.Parent.ChangeLayer(objColl, colorLayer
I have a problem with this method, because when I try to set the layer of a certain component, Inventor thinks about it for at least 20 minutes. I don't know if it ever completes the process, because I haven't waited it out. This is just too long. If I just right-click the component (in the browser) and select Properties, I can change the color and linetype (see image) and it works immediately without bogging down.
So my question is, how do I write code to automatically change the properties just like I can do manually? Is there a function I can call instead of ChangeLayer() that will do this, so I don't have to use layers?
So, this is what I came up with:
Dim drawViews As DrawingView
For Each drawViews In ThisApplication.ActiveDocument.ActiveSheet.DrawingViews
occ = drawViews.ReferencedDocumentDescriptor.ReferencedD
Dim newColor As Color
newColor = ThisApplication.TransientObjects.CreateColor(0,255,255)
Dim drawcurves As DrawingCurvesEnumerator
drawcurves = drawViews.DrawingCurves(occ)
Dim drawCurve As DrawingCurve
For Each drawCurve In drawcurves
drawCurve.Color() = newColor
This works insofar as it gets around using layers, but I still have the problem of Inventor bogging down changing the color for each edge. What I need to be able to do is write code that will do the same thing as when I right-click a component, choose Properties, and change the component color (rather than right-clicking a component, choosing "Select as edges" and then Properties > change color). When done manually, this only takes a second.
Code gurus: Can this be done? How?
Since this thread has been solved, I decided I really should start a new post here:
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register