Hide all other solid keep selected visibility in Drawing View

Hide all other solid keep selected visibility in Drawing View

ngdnam88
Advocate Advocate
753 Views
5 Replies
Message 1 of 6

Hide all other solid keep selected visibility in Drawing View

ngdnam88
Advocate
Advocate

Dears,

I'm working some drawing of multisolid part. In the drawing view, I only wanna keep 1 body visibility to work. Could you please help me, the Code can keep selected bodies visibility - all other will be hidden.

ngnam1988_0-1690431251890.png

Thank you very much!

0 Likes
Accepted solutions (1)
754 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Hi @ngdnam88.  Is this a DWG type drawing or an IDW type drawing, because your image looks like a modeling screen, instead of a drawing sheet?  I would refer you to my related responses on your other post here for some functionality/capabilities.  In the drawing, once you have created all the necessary DVR's (DesignViewRepresentations) in the model, you should be able to specify a DVR for the DrawingView to use, which I think should fix this issue pretty well for you.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6

ngdnam88
Advocate
Advocate

Hi @WCrihfield,
It's an .idw drawing. I'm trying this way because of I don't wanna change anything in the customer's model.
In the my other post, the model created by me. Thanks,

ngnam1988_0-1690461740741.png

 

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor

OK.  Thanks for the clarification.  So you would be starting the rule from a DrawingDocument, and the code should focus on one specific DrawingView.  Then it should dig into the model being shown in the view, and get a reference to its solid bodies.  Then you want to show the geometry of one specific solid body within the view, while the geometry for all the other bodies is hidden, right.  There are likely two routes that could be taken in a case like this.  We could try navigating the model browser tree of the drawing by code, the try interacting with the individual BrowserNode objects associated with the model under that view.  Or we could do things the more natural way, where we dig into the model (without actually changing the model) to get the needed references, then control which objects are included or hidden in the view by filtering the DrawingCurves within the view.  Either way, I believe the result will be sort of temporary (not locked down) though.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 6

WCrihfield
Mentor
Mentor
Accepted solution

Here is something I just threw together for you.  If first asks you to 'Pick' a DrawingView for it to process, then if the view is of a Multi-Body Part document, it will show you a list of the solid body names for you to choose one from.  Then it will ensure that body is visible in the view, while turning off visibility of all the other bodies in that view.  I have not tested it yet though.

 

Sub Main
	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
	Dim oModelDoc As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
	If oModelDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then Exit Sub
	Dim oPDoc As PartDocument = oModelDoc
	If oPDoc.ComponentDefinition.HasMultipleSolidBodies = False Then Exit Sub
	Dim oBodies As SurfaceBodies = oPDoc.ComponentDefinition.SurfaceBodies
	Dim oBodyNames As New List(Of String)
	For Each oBody As SurfaceBody In oBodies : oBodyNames.Add(oBody.Name) : Next
	Dim oBodyName As String = InputListBox("Pick A Body Name", oBodyNames, "", "Body Names")
	If oBodyName = "" Then Exit Sub
	For Each oBody As SurfaceBody In oBodies
		If oBody.Name = oBodyName Then
			oView.SetVisibility(oBody, True)
		Else
			oView.SetVisibility(oBody, False)
		End If
	Next
	oView.Parent.Update 'update the sheet
	'oView.Parent.Parent.Update ' update the drawing
End Sub

 

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

EESignature

(Not an Autodesk Employee)

Message 6 of 6

ngdnam88
Advocate
Advocate

Hi @WCrihfield 
It works perfectly! Thanks!

0 Likes