Turn of the visibility of a solid body in a drawing view with iLogic

Turn of the visibility of a solid body in a drawing view with iLogic

jgomis.ext
Enthusiast Enthusiast
387 Views
4 Replies
Message 1 of 5

Turn of the visibility of a solid body in a drawing view with iLogic

jgomis.ext
Enthusiast
Enthusiast

Hi everybody !

I would like to acces the visibility command that we have for the solid body in a view.

jgomisext_0-1675688865771.png

I have wrote a code to do it with iLogic but it's not working well. My code change the visibility in my part and not only in the model tree of my view.

Dim oDoc As DrawingDocument 
oDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
oSheet = ThisDoc.Document.ActiveSheet

Dim oView As DrawingView 
oView = oSheet.DrawingViews(1)

Dim oRefDoc As Document 
oRefDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument 

Dim oCompDef As PartComponentDefinition
oCompDef = oRefDoc.ComponentDefinition

Dim oSB1 As SurfaceBody 
oSB1 = oCompDef.SurfaceBodies(2)

oSB1.Visible = True

Do someone know what I'm doing wrong ?

Thanks for anyhelp ! 🙂

 

0 Likes
Accepted solutions (1)
388 Views
4 Replies
Replies (4)
Message 2 of 5

Daan_M
Collaborator
Collaborator

-

0 Likes
Message 3 of 5

jgomis.ext
Enthusiast
Enthusiast

Hi,

I don't want to supress my view, I just want to use only some body solid in my view...

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Hi @jgomis.ext.  You will need at least one custom DesignViewRepresentation in your DesignViewRepresentaions collection to accomplish what you are trying to do.  Then that one drawing view will have to be set to that custom DVR, so that the body visibility differences needed for that view do not effect the other drawing views.  Once that custom DVR exists in your 'model' file, you can do either of the following: 

1a)  Set the visibility of those bodies in the model, while that custom DVR is active, so those settings get recorded.

1b)  Set the drawing view to that DVR, then check the checkbox next for 'Associative' to link it.

1c)  Do not attempt to further adjust any visibility of stuff in that drawing view.

or

2a)  Do not mess with visibility in the model directly, but do set the drawing view to that custom DVR, but then do not check the checkbox for 'Associative', because you will be adjusting body visibility from the drawing side, which would break any associativity.  Body visibility will still be effecting the model, but only that one custom DVR version of the model, if things are done right.  Leaving your other drawing views (which are set to the 'Master/Locked' DVR, instead of the custom one) alone/unchanged.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 5

WCrihfield
Mentor
Mentor

By the way, here is another route for controlling the visibility of SurfaceBody geometry within a drawing view of a multi-body part.  This simple example uses a property of the DrawingView object called DrawingCurves, which will retrieve all view geometry for the model reference you input into it.  Then you can loop through the contents of that collection of geometry to turn the visibility of the geometry off.  This example is just getting the first view on the active sheet of the drawing, then attempting to get the third body in the part, but you can change any of that as needed.

Dim oDDoc As DrawingDocument = ThisDoc.Document
Dim oView As DrawingView = oDDoc.ActiveSheet.DrawingViews.Item(1)
Dim oModel As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
If oModel.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
	Dim oPDoc As PartDocument = oModel
	If oPDoc.ComponentDefinition.HasMultipleSolidBodies = False Then Exit Sub
	Dim oBodies As SurfaceBodies = oPDoc.ComponentDefinition.SurfaceBodies
	Dim oBody3 As SurfaceBody = oBodies.Item(3)
	Dim oBodyGeomInView As DrawingCurvesEnumerator = oView.DrawingCurves(oBody3)
	If oBodyGeomInView.Count = 0 Then Exit Sub
	For Each oDC As DrawingCurve In oBodyGeomInView
		For Each oDCS As DrawingCurveSegment In oDC.Segments
			oDCS.Visible = False
		Next
	Next
End If

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)

0 Likes