IDW Flat Pattern Feature layer change

IDW Flat Pattern Feature layer change

ratsilva
Explorer Explorer
702 Views
9 Replies
Message 1 of 10

IDW Flat Pattern Feature layer change

ratsilva
Explorer
Explorer

Hi All,

 

I have searched the forum high and low but can't quite find the solution to my ilogic problem.

 

I'm trying to create a rule that will change the "Embross1" feature edges to a new layer with the name "MARKY"

 

ratsilva_1-1658245667281.png

In our company we need the feature to be a in separate layer so that the laser cutting software can recognize and consider the feature as an engraving element. I have been at this for days with no avail, so any help in the write direction would be very appreciated.  

 

@Curtis_Waguespack has done some great work around similar topics. 

 

0 Likes
Accepted solutions (1)
703 Views
9 Replies
Replies (9)
Message 2 of 10

WCrihfield
Mentor
Mentor
Accepted solution

Hi @ratsilva.  You can give this iLogic rule a try if you would like.

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
Dim oModel As PartDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oSMDef As SheetMetalComponentDefinition = oModel.ComponentDefinition
Dim oFP As FlatPattern = oSMDef.FlatPattern
Dim oEmboss1 As EmbossFeature = oFP.Features.EmbossFeatures.Item("Emboss1")
Dim oDCurves As DrawingCurvesEnumerator = oView.DrawingCurves(oEmboss1)
Dim oLayer As Layer = oDDoc.StylesManager.Layers.Item("MARKY")
For Each oDCurve As DrawingCurve In oDCurves
	For Each oCS As DrawingCurveSegment In oDCurve.Segments
		oCS.Layer = oLayer
	Next
Next

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS :bulb: or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 10

ratsilva
Explorer
Explorer

ho my god @WCrihfield !!! it WORKED PERFECTLY !!!  I was going crazy trying to do this but found no real way of doing what you did ...

How did you manage to do this ?

Thankyou x1000

0 Likes
Message 4 of 10

bbailey6E5PN
Contributor
Contributor

Hello @WCrihfield I am in the same boat... I would like to edit this to use the mark feature instead of emboss. I have modified the code to the following:

Dim oDDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
Dim oModel As PartDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oSMDef As SheetMetalComponentDefinition = oModel.ComponentDefinition
Dim oFP As FlatPattern = oSMDef.FlatPattern
Dim oMark1 As MarkFeature = oFP.Features.MarkFeatures.Item("Mark1")
Dim oDCurves As DrawingCurvesEnumerator = oView.DrawingCurves(oMark1)
Dim oLayer As Layer = oDDoc.StylesManager.Layers.Item("Scribe")
For Each oDCurve As DrawingCurve In oDCurves
	For Each oCS As DrawingCurveSegment In oDCurve.Segments
		oCS.Layer = oLayer
	Next
Next

I have attached at snippet of what happens. Instead of modifying only the mark layer, it modifies the whole part. 

bbailey6E5PN_0-1698941061534.png

Any help on this would be great!! Thank you!

0 Likes
Message 5 of 10

WCrihfield
Mentor
Mentor

Hi @bbailey6E5PN.  I downloaded your part, created a new drawing, added two base views to it (folded & flat pattern) for that part, then created this iLogic rule in that drawing.  When I ran it, it did the same thing as your image (colored outside edges of part too).  I am not sure why it did that.  I have not really used the new Mark features for anything work related, so I am not super familiar with them yet.  I tried changing the feature to 'Mart Through' instead of 'Mark Surface', but that did not seem to help.  It acts like the outer edges of the surface are part of the feature, but that does not seem logical to me.  Maybe someone at Autodesk could explain that better than me right now.

 

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
	Dim oDDoc As DrawingDocument = ThisDoc.Document
	Dim oSheets As Inventor.Sheets = oDDoc.Sheets
	Dim oTO As TransientObjects = ThisApplication.TransientObjects
	Dim oLayers As LayersEnumerator = oDDoc.StylesManager.Layers
	Dim oLayer As Layer = Nothing
	Try
		oLayer = oLayers.Item("Scribe")
	Catch
		oLayer = oLayers.Item(1).Copy("Scribe")
		oLayer.Color = oTO.CreateColor(127, 127, 0) 'shooting for yellow
	End Try
	Dim oColl As ObjectCollection = oTO.CreateObjectCollection
	For Each oSheet As Inventor.Sheet In oSheets
		Dim oViews As DrawingViews = oSheet.DrawingViews
		If oViews.Count = 0 Then Continue For 'skip to next sheet
		For Each oView As DrawingView In oViews
			If oView.IsFlatPatternView = False Then Continue For
			Dim oPDoc As PartDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
			Dim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
			Dim oFPMF As MarkFeature = oSMDef.FlatPattern.Features.MarkFeatures.Item("Mark1")
			Dim oDCs As DrawingCurvesEnumerator = Nothing
			Try : oDCs = oView.DrawingCurves(oFPMF) : Catch : End Try
			If oDCs Is Nothing OrElse oDCs.Count = 0 Then Continue For
			For Each oDC As DrawingCurve In oDCs
				For Each oDCSeg As DrawingCurveSegment In oDC.Segments
					oColl.Add(oDCSeg)
				Next 'oDCSeg
			Next 'oDC
		Next 'oView
		If oColl.Count > 0 Then
			oSheet.ChangeLayer(oColl, oLayer)
			oColl.Clear
		End If
		oSheet.Update
	Next 'oSheet
	If oDDoc.RequiresUpdate Then oDDoc.Update2(True)
End Sub

 

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 10

bbailey6E5PN
Contributor
Contributor

@WCrihfield you are absolutely right.. This mark feature isn't far enough along yet. In the "Idea's" page I suggested to them to allow the Mark feature layer to be modified by "Object Defaults". That would be a simpler solution for them. 

 

Your code does work PERFECTLY for the Emboss. So I am unsure why as well. I am also very new to coding iLogic. I am currently trying to find a good book I can study. 

 

Thank you for your reply. I really appreciate you trying it. 

Message 7 of 10

WCrihfield
Mentor
Mentor

Good idea. Did you just create an idea in the Inventor Ideas forum for this?  If so, please post a link to it here, so it might get a bit more exposure.  I will vote for it too, to help it along.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 8 of 10

bbailey6E5PN
Contributor
Contributor

Here is the link to the Idea. It was back in August. 

 

https://forums.autodesk.com/t5/inventor-ideas/layers/idi-p/12141868

0 Likes
Message 9 of 10

WCrihfield
Mentor
Mentor

OK, thank you.  I voted for it.  But I think we do have control over the 'Sketched Symbols' layer, at least in 2024 version.  I'm not sure when it was added though, because I have not payed much attention to Inventor drawing layers over the years.  Below is a screen captured area of the list within one of my Object Defaults styles.  It was not where I was expecting it though.  I was expecting there to be a Layer named something like "Sketch Symbols" or "Sketched Symbols", but they have them listed as "User Defined Symbol".  They even separated it into 3 potential ways to control it.

WCrihfield_0-1698947295160.png

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 10 of 10

bbailey6E5PN
Contributor
Contributor

Thank you for noticing that. They must have added that recently! That's great news. 

0 Likes