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: 

Assign Layers to Materials

77 REPLIES 77
SOLVED
Reply
Message 1 of 78
Anonymous
10012 Views, 77 Replies

Assign Layers to Materials

Is there a way to associate layers to materials so when they are placed in a drawing they are automatically placed on the proper layer. I have line weights set for each individual layer and would like each material component to have its own line weight.

77 REPLIES 77
Message 21 of 78
MjDeck
in reply to: Anonymous

Can you list some more layer names that you would need in a typical drawing?  That will help me to put together a sample table in the rule.


Mike Deck
Software Developer
Autodesk, Inc.

Message 22 of 78
Anonymous
in reply to: MjDeck

00-Framing

00-Tile

00-Glass

00-Metal

00-Mirror

00-Others

00-Rough Wall

00-Hatch

Message 23 of 78
MjDeck
in reply to: Anonymous

Can you list them with the color names added, similar to:

 

00-Stone-Cyan

00-Stone-Magenta


Mike Deck
Software Developer
Autodesk, Inc.

Message 24 of 78
MjDeck
in reply to: Anonymous

I was thinking of having the program (or rule) create the layers if they don't already exist.  But if you need different colors and line weights, it would get complicated.  Maybe the program will rely on the layers already being there.  You can add them to your Style Library (if you haven't done that already) so that they are always available in a new drawing.  Does that sound like a good way to go?

 

A few more questions:

What will go on the 00-Stone-Yellow layer?

 

Taking for example 00-Framing-Grey : 

Do you have a material named 00-Framing?

Do you want all parts that are made of that material show up on the 00-Framing-Grey layer, no matter what kind of view (projected, section etc.) they are in?

 

About the 00-Text-  layers:

As it is now, the program doesn't change the layer of text.  Do you want it to do something, or are you planning to change or assign the layer of your text manually?

 

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 25 of 78
MjDeck
in reply to: Anonymous

OK, it looks like this applies to all materials:

 

The layer for:

Solid lines in a plan or projected view:       MaterialName

Hidden lines in a plan or projected view:    MaterialName-Hidden

Solid lines in any other view:                      MaterialName-VIew

Hidden lines in any other view:                  MaterialName-View-Hidden

 

That should be easy for the rule to do.

 

About 00-Hatch-Grey: you don't have any Hidden layer listed for that.  Does it need special treatment Are you not expecting any hidden lines for that material?


Mike Deck
Software Developer
Autodesk, Inc.

Message 26 of 78
MjDeck
in reply to: Anonymous

Here's a new version of the rule to change the layers.  This will look for the layers:

 

Solid lines in a plan or projected view:       MaterialName

Hidden lines in a plan or projected view:    MaterialName-Hidden

Solid lines in any other view:                      MaterialName-VIew

Hidden lines in any other view:                  MaterialName-View-Hidden

 

It will create the hidden layers automatically if they are not found.  If there are any other missing layers it will show a message.

 

 It gives you some flexibility to assign layers manually after the program runs.  I don't know if you need this.  I can take it out if you want.  How it works:  If you change the layer of some lines to a new layer that starts with the material name, the program won't change them back the next tiem it runs.  For instance, if a line was on 00-Stone-Green, you could create a new layer named 00-Stone-Green-Extra and manually change the line to go on that layer.

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 27 of 78
Anonymous
in reply to: MjDeck

Ok, Thank you very much

We are grateful for all your hard work and patience.

 

We will test out the new rule and keep you posted.

Message 28 of 78
Anonymous
in reply to: MjDeck

We are beginning to utilize the rule within our office. When we begin inserting our views and run the rule everything works great. After we are finished dressing up the drawing with dimensions, text & leaders we get an error message when we try and save. Our event trigger is set to run the rule when we save, however the error comes up and it won't allow us to save. We took the rule of the event trigger and we save the document but the rule won't work anymore. The error appears when we run the rule manually. Attached you will find the error message we are receiving.

 

Thank you

Message 29 of 78
MjDeck
in reply to: MjDeck

Here's a new version.  Please try it and see if it runs without the error.


Mike Deck
Software Developer
Autodesk, Inc.

Message 30 of 78
Anonymous
in reply to: MjDeck

Mr. Deck,

 

We are utilizing your code frequently and it is helping us out a tremendously. We are noticing that when we save, it is taking a very long time for that process to complete. This is happening when the drawing view has a lot of lines to convert. Is there any way to speed that process up a little from within the code? Even after it convert everything when we save the file again it takes awhile and occasionally Inventor says "Not Responding" and the screen goes white for a while. One other thing, would it be possible to include ipn files to the code as well. Thank you

Message 31 of 78
Anonymous
in reply to: MjDeck

Deck,

 

After we updated to 2012, we are receiving errors. Would you be able to guide us in the right direction in regards to hiring a software programmer to help fix minor issues and also create more ilogic code for us. Thank you

Message 32 of 78
MjDeck
in reply to: Anonymous

Are you seeing errors coming from the iLogic rule that assigns drawing layers?  I might be able to help with that.  What are the errors you're seeing?   If the error dialog has a More Info tab, please click on that and post the contents (as text, not as a screenshot).

 About hiring a programmer: I'm not sure what to recommend.  Maybe you'll get some response from this post.   Or you could try posting a new topic (just about that) on this forum.


Mike Deck
Software Developer
Autodesk, Inc.

Message 33 of 78
Anonymous
in reply to: MjDeck

Mike,

 

Thank you for your reply, the error is occurring right after we generate a section of a part. And 2012 crashes when we insert a part into a drawing environment. When I delete the rule there are times it doesn't crash.

 

Also when we insert a ipn file the rule doesn't work as well. I think that required a code update.

 

see error below:

 

Error Message

 

Error in rule: Drawing Layers By Material, in document: Form1.dwg

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

 

More info

 

System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))

at LmiRuleScript.ChangeLayerOfOccurrenceCurves()

at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)

at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

Message 34 of 78
MjDeck
in reply to: Anonymous

Please try this new version of the rule.  It probably won't fix the error, but it might provide a better error message.  If the error message it shows is different in any way, please copy and paste the text again.

 

> And 2012 crashes when we insert a part into a drawing environment. When I delete the rule there are times it doesn't crash.

I don't know if the crash has anything to do with the rule.  The rule only runs when you save the document (or you can run it manually). 

 If you want me to look at the crash, can you send me your drawing, assembly and parts?  If you can Pack and Go it to a .zip file of size 10 Meg or less you might be able to email it.  My email is mike dot deck  at    the company name at the top of this page   dot com.

 

 Sorry, but iLogic rules aren't supported in presentation (.ipn) documents.


Mike Deck
Software Developer
Autodesk, Inc.

Message 35 of 78
Anonymous
in reply to: MjDeck

Error Message

 

Error in rule: Drawing Layers By Material, in document: Form Tickets.dwg

Object reference not set to an instance of an object.

 

More Info

 

System.NullReferenceException: Object reference not set to an instance of an object.

at LmiRuleScript.MaterialLayers.SetDrawingCurvesLayer(Application app)

at LmiRuleScript.ProcessOccurrences(DrawingView drawView, ComponentOccurrences Occurrences)

at LmiRuleScript.ChangeLayerOfOccurrenceCurves()

at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)

at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

Now when we save we get:

 

Microsoft Visual C++ Runtime Library

 

Runtime Error!

Program: c:\Program Files\Autodesk\Inventor 2012\Bin\Inventor.exe

R6025

-pure virtual function call

 

 

 

And Inventor then crashes when we select <ok>

 

Message 36 of 78
MjDeck
in reply to: Anonymous

Here's a new version of the rule.  See if this will run without an error.

If you still get an error message or if Inventor crashes, please try deleting the rule completely and see if you can save the drawing without an error or crash. 

 If it still crashes, can you go back to an older version of the drawing, and delete the rule there?  Try to save it without the rule (maybe first make a change such as adding a section view).  If it saves OK, try adding the new version of the rule and see if it will save.

 


Mike Deck
Software Developer
Autodesk, Inc.

Message 37 of 78
Anonymous
in reply to: Anonymous

Hi Mike,

 

Just wanted to say thanks for this really useful code.  I have been testing it and it works great for a purpose I require.....

 

I am using it to do as described in the thread but also I want to find a way to apply a colour fill to profiles based on the material.  I have therefore applied this code to allow me to leave only the parts of the material I want the fill to be applied to as visible before I manually apply a sketch>project geometry>fill.  It certainly aids the process but I was wondering if this is something which the code could be adapted to include?

 

Thanks again for the great work.

 

Regards,

Guy

Message 38 of 78
MjDeck
in reply to: Anonymous

Guy,

 

 Do you want:

A) A program to automatically create sketches and fill profiles and change the colors? 

 or

B) You create each fill manually, and then use a program to change the color of the fill to match the profile?

 

B) might be possible, but A) would probably require a lot of work.


Mike Deck
Software Developer
Autodesk, Inc.

Message 39 of 78
Anonymous
in reply to: MjDeck


@MjDeck wrote:

Guy,

 

 Do you want:

A) A program to automatically create sketches and fill profiles and change the colors? 

 or

B) You create each fill manually, and then use a program to change the color of the fill to match the profile?

 

B) might be possible, but A) would probably require a lot of work.


Hi Mike,

 

Ideal situation is a program which will create a sketch on a drawing view and then fill the profiles with a solid colour.  This would really improve our drawing production speed.  I wondered if this come be aided by the layers program you wrote here to simplify the task because you can switch only one active layer on and then apply the fill?

 

Currently we only require the aluminium profiles having the fill applied as this is the standard style for the documentation.

 

Your help is appreciated.

 

Basic example without fill attached.

 

Cheers,

Guy

 

Message 40 of 78
MjDeck
in reply to: Anonymous

Guy,

 

 Have you tried using shaded views?  Or do you want to selectively fill profiles, and shaded views don't give you the control that you need?

 


Mike Deck
Software Developer
Autodesk, Inc.

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report