Hi,
i found this thread:
the code works but i'd like to adapt it.
instead of phantom i need to be a continuous line in magenta.
i have the choice to either:
only change the colour or assign the surface line to a layer in magenta colour.
i see i can change the number behind the
StylesManager.Layers.Item
but i have no idea to which layer the number corresponds to.
is there a list?
i'm considering creating a layer called "Etched Lines" with continuous lines in Magenta (R255, G0, B255)
could the ilogic gurus do their magic please?
thanks.
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Hi @romu51. The layers can be customized, so the 'Index' number way of accessing them is not a very good way if you want a specific one. You can specify the internal name of the layer instead of its index number there if you want. What is the scope of your request? (Do you want the code to effect every view on every sheet of a multi-sheet drawing ; or do you only want to work with one specific view, or somewhere between? Please specify.) Would you prefer to simply pick the view you want the code to work on manually, instead of trying to find it by code? Do you want it to effect all geometry in the view from every possible WorkSurface type object in the model, or just one specific one? The Layer route is generally better, because you can change how a Layer looks later in the Layers dialog if you want, outside of the code, without needing to change the code itself. There is a quicker way though. You can collect all drawing curve segments into an ObjectCollection, then use the Sheet.ChangeLayer() method to change them all to a specified layer at one time, instead of individually. Less processing that way.
Wesley Crihfield
(Not an Autodesk Employee)
Hi @WCrihfield ,
thank you for the reply.
I understand the "index" is made of "volotile" references where every style library makes it different.
I was looking at creating a new layer to display what i want but my knowledge of coding is limited.
The scope would be to have the code to effect one view only but i cant guaranty it would always be the same (ie front). It would be nice to be prompted to choose which view it would be applicable to.
we don't use surfaces much so i'm happy to display all surface curves and have them all in one layer.
So your suggestion to collect all curves and have them all on that new layer works for me.
I'd need to code to activate the "Include Surface Bodies" tick box as this works well to display the surface curves.
Hi @romu51. Below is an iLogic rule you can try for that task. I have not tested it yet myself, so I am not 100% sure if it will work yet, because WorkSurface is not one of the object types listed that we can use as input into the DrawingView.DrawingCurves property to get its curves. If this fails, we may have to go an additional step (or few) deeper by exploring into the WorkSurface.SurfaceBodies property, if this is even possible.
oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kDrawingViewFilter, "Select a Drawing View.")
If IsNothing(oObj) OrElse (TypeOf oObj Is DrawingView = False) Then Exit Sub
Dim oView As DrawingView = oObj
oView.IncludeSurfaceBodies = True
Dim oSheet As Inventor.Sheet = oView.Parent
oModelType = oView.ReferencedDocumentDescriptor.ReferencedDocumentType
If oModelType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("The view must be of a Part, not an Assembly, because only Parts have WorkSurfaces.",,"")
Exit Sub
End If
Dim oViewPDoc As PartDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oWSs As WorkSurfaces = oViewPDoc.ComponentDefinition.WorkSurfaces
If oWSs.Count = 0 Then
MsgBox("There were no WorkSurfaces found in the Part in the selected view.",,"")
Exit Sub
End If
Dim oObjCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
For Each oWS As WorkSurface In oWSs
Dim oDCurves As DrawingCurvesEnumerator = Nothing
Try : oDCurves = oView.DrawingCurves(oWS) : Catch : End Try
If IsNothing(oDCurves) OrElse oDCurves.Count = 0 Then Continue For 'skip to next oWS
For Each oDC As DrawingCurve In oDCurves
Dim oDCSs As DrawingCurveSegments = oDC.Segments
For Each oDCS As DrawingCurveSegment In oDCSs
oObjCol.Add(oDCS)
Next
Next
Next
If oObjCol.Count = 0 Then Exit Sub
Dim oDDoc As DrawingDocument = oSheet.Parent
Dim oLayer As Inventor.Layer = Nothing
Dim oLayerCreated As Boolean = False
Try
oLayer = oDDoc.StylesManager.Layers.Item("WorkSurface Curves")
Catch
oLayer = oDDoc.StylesManager.Layers.Item(1).Copy("WorkSurface Curves")
oLayerCreated = True
End Try
If oLayerCreated Then
oLayer.Color = ThisApplication.TransientObjects.CreateColor(255, 0, 0) 'Pure Red
oLayer.LineType = LineTypeEnum.kContinuousLineType
'oLayer.LineWeight = .01 'in centimeters
oLayer.Plot = True
oLayer.Visible = True
'oLayer.SaveToGlobal
End If
oSheet.ChangeLayer(oObjCol, oLayer)
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.