I am trying to set hidden lines for the following component in my view: VIEW1, 000076253.iam, N1 + N3, 000078783:1.
So far i have had no succes in selecting anything with iLogic past the view.
I want to show hidden lines for 000078783:1 automatically.
The reason why i need to do this is so that the component shows up on the drawing view. My model is parametric so for some configurations 000078783 is not visible, if it becomes visible in a later configuration hidden lines are off again. So i need a way to toggle them if needed.
I found a way to target the modeldocument behind a view, but i am not certain how to proceed:
Dim oSheet As Sheet = ThisDoc.Document.ActiveSheet Dim oView As DrawingView = oSheet.DrawingViews.Item(1) ' Specify the view name Dim modelDocument As Document = oView.ModelDocument
Any help or links to the documentation would be greatly appreciated!
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi @Mario.van.der.raaf. What you are wanting to do is a somewhat complicated, and highly custom task to automate. One of the main tools for accomplishing what you want to do is the DrawingView.DrawingCurves property, which acts a bit like a Function. You can supply a model object as input, and it will return the geometry objects currently visible within that view for that object (if any). But before you can effectively use it, you will first need to get a reference to the model geometry needed as the input. Once you have a reference to the model document object that is referenced within the DrawingView, you can then proceed to dig down within its ComponentDefinition.Occurrences collection, to access the specific ComponentOccurrence (or ComponentOccurrenceProxy) object, and set that as the value of that type of a ComponentOccurrence type variable. Once you have that, you can use it in that DrawingCurves property to get the DrawingCurvesEnumerator collection representing the DrawingCurves within that view which represent that component. Then you can loop through those DrawingCurve objects, and may also need to loop through the DrawingCurveSegment objects within each DrawingCurve object to change them. You can either change them individually, which often takes longer to process, and is more difficult to change again later if needed. Or you can collect each of them into an ObjectCollection, then use the Sheet.ChangeLayer method to change them all to a specific layer at once, which is set-up the way you want it.
By the way, the standard API way to access the model document being referenced by a DrawingView is like this:
Dim oViewDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
Wesley Crihfield
(Not an Autodesk Employee)
If you're trying to set this check box, then this example might work.
Sub Main
aVName = "VIEW1"
sCompName = "000078783:1"
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDrawingDoc.ActiveSheet
For Each oView In oSheet.DrawingViews
If oView.Name = aVName Then
'Get the browser node definition of the drawing view
Dim oNativeBrowserNodeDef As NativeBrowserNodeDefinition
oNativeBrowserNodeDef = oDrawingDoc.BrowserPanes.GetNativeBrowserNodeDefinition(oView)
'Get the top browser node
Dim oTopBrowserNode As BrowserNode
oTopBrowserNode = ThisApplication.ActiveDocument.BrowserPanes.ActivePane.TopNode
' Get the browser node of the view
Dim oNode As BrowserNode
oNode = oTopBrowserNode.AllReferencedNodes(oNativeBrowserNodeDef).Item(1)
Call recurseNodes(oNode, sCompName)
Exit Sub
End If
Next oView
End Sub
Sub recurseNodes(node As BrowserNode, sName As String)
'See if the node label is the name of the component
If node.BrowserNodeDefinition.Label = sName Then
'Expand the node
Try : node.Expanded = True: Catch : End Try
'Select the node
node.DoSelect()
CmdMan = ThisApplication.CommandManager
CmdMan.ControlDefinitions.Item("DrawingBodyHiddenLinesCtxCmd").Execute
NodeFound = True
End If
If NodeFound = True Then Exit Sub
Dim bn As BrowserNode
For Each bn In node.BrowserNodes
If NodeFound = False Then
Try
If Not TypeName(bn.NativeObject) = "DrawingView" Then
Call recurseNodes(bn, sName)
End If
Catch
Exit Sub
End Try
End If
Next
End Sub
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Thanks for all the replies, what I did in the end is create a new part which changes dimensions using iLogic to suite my entire model range. This way I could leave the part active and prevent it from resetting the hidden lines feature. This proved easier and solved another issue my previous approach had, which was that the part i wanted to show had a lot of internal feature which would make the drawing messy.
Can't find what you're looking for? Ask the community or share your knowledge.