
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all,
since a long time I'm dreaming of a Macro to automate the following process that we use every day. We use it to highlight connectors so people can build our product easier.
We manually do the following:
In a drawing view we select a whole set of components (the connectors). Afterwards we change the color to green (using properties) & press hidden lines. This way you can clearly see where you need to place the connectors.
-> see .pdf attached with some pictures making it all clear
I'm being busy to create the code for this but I'm stuck over adding occurrences to a selection set so I can then apply the hidden line command
This is my code so far:
Sub AutoColor() 'Step 1 Select a drawing view ' Get the active drawing document. Dim drawDoc As DrawingDocument Set drawDoc = ThisApplication.ActiveDocument ' Have the user select a drawing view. Dim drawView As DrawingView Set drawView = ThisApplication.CommandManager.Pick(kDrawingViewFilter, "Select a drawing view.") Dim docDesc As DocumentDescriptor Set docDesc = drawView.ReferencedDocumentDescriptor ' Verify that the selected drawing view is of an assembly. If docDesc.ReferencedDocumentType <> kAssemblyDocumentObject Then MsgBox "The selected view must be of an assembly." Exit Sub End If ' Get the component definition for the assembly. Dim asmDef As AssemblyComponentDefinition Set asmDef = docDesc.ReferencedDocument.ComponentDefinition 'Step 2 Call the function that selects the correct occurrences Call SelectOcc(drawView, asmDef.Occurrences) 'Step 3 change to hidden lines Dim oControlDef As ControlDefinition Set oControlDef = ThisApplication.CommandManager.ControlDefinitions.Item("DrawingBodyHiddenLinesCtxCmd") oControlDef.Execute 'Step 4 for all components in selection, select all lines of them 'Step 5 place all lines on new layer with green color End Sub Private Sub SelectOcc(drawView As DrawingView, Occurrences As ComponentOccurrences) ' Iterate through the current collection of occurrences. Dim occ As ComponentOccurrence For Each occ In Occurrences 'check if the occurence is the folder "03 PARTS", if it is then proces, else ignore ' the file location should be adjusted so it suits your files Dim OccFullLocation As String OccFullLocation = occ.ReferencedDocumentDescriptor.FullDocumentName If Left(OccFullLocation, 33) = "O:\04 R&D\08 beCAD 2013\03 PARTS\" Then 'MsgBox ("It is a part") ' ' '<<<<<HERE SHOULD BE THE CODE TO ADD THE OCC TO THE SELECTIONSET>>>> ' End If Next End Sub
Step 1 works
Step 3 works
Step 4 & 5 are for a later moment
Step 2 calls the sub "SelectOCC". this sub cycles true the occurrences, I can filter them on file location so I only get the components needed (the connectors). In theory it should be possible to add the given occurrences to the selection set so I can run Step 3 afterwards on it.
But I don't succeed in doing this, I've tried countless of methods and went to this forum and the help but without success 😞
for the man (woman) helping me: Thanks!
Solved! Go to Solution.