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 based on Custom iProperty

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
1180 Views, 5 Replies

Assign Layers based on Custom iProperty

I'm wondering if there is a way to assign parts to a drawing layer based on a layer name in a custom iProperty?

 

It would be a lot like the iLogic rule provided in this discussion ('Assign Materials to Layers') http://forums.autodesk.com/t5/Inventor-Customization/Assign-Layers-to-Materials/td-p/2871324/page/5but rather than look at the material, it would look at a custom property named "Layer". 

 

I have multiple parts which use the same material (I want the material spec to appear the same in the parts list), but I want to place them on different layers using iLogic rather than going through a large assembly, finding all individual parts, selecting as edge and then changing the layers manually.

 

Any help would be greatly appreciated.

5 REPLIES 5
Message 2 of 6
philippe.leefsma
in reply to: Anonymous

Hi Adam,

 

We usually don't write code based on your requests, but we can provide guidance. What you are asking seems doable, it is rather straighforward to access iProperties and affect components to a specific layer in a drawing. You should be able to easily find VBA sample to achieve that by looking at the API Help Files or through our blogs and forums.

 

You can set the DrawingCurveSegment.Layer Property to the desired layer. You can use the 

DrawingView.DrawingCurves( [ModelObject] As Variant ) method to retrieve all the curves that represent a specific part or component from the model in your drawing. Also the Sheet.ChangeLayer method allows to change layer for a set of curves at once and enhances performances comparing to changing layer curve by curve.

 

If you have some more specific questions on how to achieve a precise task with the API, I'll be happy to point out how you can do it.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 6
Anonymous
in reply to: philippe.leefsma

Hey Philippe,

 

Thanks for getting back to me. I'm very new to programming and Inventors API so I'm afraid I'm struggling a little with this one. 

 

I've been trying to modify routine from Mike Deck on the "Assign Layers to Materials" discussion (attached), but dont seem to be getting very far. I was thinking that it might be as simply as changing the: 

 

materialName = partDoc.ComponentDefinition.Material.Name

to reference the part custom iProperty called "Layer" 

 

iProperties.Value("Custom", "Layer")

But I'm not sure how to reference iProperties for individual parts, rather than the iproperties within the drawings. I cant seem to find any similar examples.

 

Any help is really appreciated. Thanks again.

 

Adam

Message 4 of 6
philippe.leefsma
in reply to: Anonymous

Internet should be your front line resource when getting started, googling the keyword combination "ilogic iproperty occurrence" leads me on the first hit to that post that contains a sample:

 

http://forums.autodesk.com/t5/Inventor-General/iLogic-Assembly-Component-Occurrence-Definition/td-p/...

 

' set a reference to the assembly component definintion.
' This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
    Dim oName As String
    oName = oOccurrence.Name
   iProperties.Value(oOccurrence.Name, "Project", "Part Number") = oName
    MessageBox.Show(oOccurrence.Name, "iLogic")
Next

Hope that helps,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 5 of 6
Anonymous
in reply to: philippe.leefsma

Philippe,

 

Thanks for your help. I guess with my limited knowledge of programming this is a little beyond my capabilities. I've only just started to try and teach my self in the last couple of months, and I can see I need to learn to walk before I can run. 

 

Hopefully someone else can maybe take a look at this, because I think its got a lot of potential. I've never had much use for layers in Inventor until working in the structural design industry for the last 2 years (previously I was 7 years in Mechanical Design). In structural they are very useful to delineate scope, make complex drawings more easy to read, and when transferring details to work in AutoCAD. 

 

Right now its a real pain to try and go down multiple separate sub assemblies to try and find the multiple steel parts that you want to put on a different layer, say for a example a layer called "By Others" where every other steel part is on another layer. If this was done at the part level with a layer reference, and then simply runing the iLogic routine in the drawing and having every part set to the correct layer, that would be fantastic. 

 

 

Message 6 of 6
Kyle.Arnold
in reply to: Anonymous

I'd like to bump this old thread and see if there's anyone out there who has the knowledge to make this happen. Anyone out there at all?

Thanks!

Kyle Arnold
Inventor Certified Professional

"Try not. Do or do not, there is no try." -Yoda

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

Post to forums  

Autodesk Design & Make Report