Simply way to figure out which drawing view a dimension (or any other annotation object) belongs

 

Hi everyone,

 

I'm new to the Solid Edge API and am wondering if there's an easy way to figure out whether a dimension, textbox, weldsymbol, etc. belongs to a particular drawing view on a sheet. I believe this topic was brought up a while back where using the GetRelated method on the dimension might be one route to eventually figure it out but I did not see a clear resolution on all the steps needed to actually make it work in the end.

Any suggestions would be appreciated....

Figuring it out for dimensions would the most important for now but hopefully the idea can be extended to the other annotation types.

 

Thanks,

Mark

 

 

Posted by: Mark Nalevanko
Post date: 6/16/2009 5:49:44 AM

6 REPLIES

RE: Simply way to figure out which drawing view a dimension (or any other annotation object) belongs

I noticed there's a RetrieveDimensions method on the dimension interface but I don't understand how it can be utilized as it does not return any objects ????

 

Posted by: Mark Nalevanko
Post date: 6/16/2009 5:51:19 AM

RE: Simply way to figure out which drawing view a dimension (or any other annotation object) belongs

Sorry but I meant the RetrieveDimensions method is on the DrawingView interface

 

Posted by: Mark Nalevanko
Post date: 6/16/2009 5:52:20 AM

RE: Simply way to figure out which drawing view a dimension (or any other annotation object) belongs

 

Hi Mark,

Forget about RetrieveDimensions. Getrelated is what you are looking for.

here is a VBNet example, copy and paste in a form:

PublicClass Form1Dim oSE As SolidEdgeFramework.ApplicationDim oDFT As SolidEdgeDraft.DraftDocumentDim oDim As SolidEdgeFrameworkSupport.DimensionDim oDWGView As SolidEdgeDraft.DrawingViewPrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim oGraphObject AsObject = Nothing, keypoint AsBoolean, o2Dobject AsObject Dim x AsDouble, y AsDouble, z AsDouble, n AsIntegeroSE = GetObject(, oDFT = oSE.ActiveDocument "solidedge.application")'Example. I get the first dimension i placed in my DFT.oDim = oDFT.ActiveSheet.Dimensions.item(1) 'I get the number of related objects (it could be dettached)oDim.GetRelatedCount(n) If n > 0 Then 'Get the first object related to the dimension (it normally can be 1 or two)oDim.GetRelated(0, oGraphObject, x, y, z, keypoint) 'I'm supposing that the dimension is pointing a 2D object inside the drawing view. 'This way, the object returned by getRelated should be a Reference object 'I get the 2d object with Reference.Object property. 'We obtain the 2D entity inside the view pointed by the dimension.o2Dobject = oGraphObject.object 'This object can be: ' a DVline2d, DVCircle2d, etc. if the 2d element comes from a 3D model ' or a Line2D, Circle2d, etc if it was drawn inside the drawing view. 'If the object is a DV* object we can ask for the drawing view. 'If not, i don't know how to get the drawing view object.  TryoDWGView = o2Dobject.drawingviewMsgBox( MsgBox( "Dimension '" & oDim.DisplayName & "' belongs to drawing view '" & oDWGView.Name & "'")Catch ex As Exception"The object is not a DV* object")EndTry EndIf EndEndSubClass      

 

Posted by: Julian Guillo
Post date: 6/18/2009 6:50:47 AM

RE: Simply way to figure out which drawing view a dimension (or any other annotation object) belongs

 

Sorry!

I forgot about the "Source" button to paste code.

Here it goes again:

 Public Class Form1 Dim oSE As SolidEdgeFramework.Application Dim oDFT As SolidEdgeDraft.DraftDocument Dim oDim As SolidEdgeFrameworkSupport.Dimension Dim oDWGView As SolidEdgeDraft.DrawingView Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oGraphObject As Object = Nothing, keypoint As Boolean, o2Dobject As Object Dim x As Double, y As Double, z As Double, n As Integer oSE = GetObject(, "solidedge.application") oDFT = oSE.ActiveDocument 'Example. I get the first dimension i placed in my DFT. oDim = oDFT.ActiveSheet.Dimensions.item(1) 'I get the number of related objects (it could be dettached) oDim.GetRelatedCount(n) If n > 0 Then 'Get the first object related to the dimension (it normally can be 1 or two) oDim.GetRelated(0, oGraphObject, x, y, z, keypoint) 'I'm supposing that the dimension is pointing a 2D object inside the drawing view. 'This way, the object returned by getRelated should be a Reference object 'I get the 2d object with Reference.Object property. 'We obtain the 2D entity inside the view pointed by the dimension. o2Dobject = oGraphObject.object 'This object can be: ' a DVline2d, DVCircle2d, etc. if the 2d element comes from a 3D model ' or a Line2D, Circle2d, etc if it was drawn inside the drawing view. 'If the object is a DV* object we can ask for the drawing view. 'If not, i don't know how to get the drawing view object. Try oDWGView = o2Dobject.drawingview MsgBox("Dimension '" & oDim.DisplayName & "' belongs to drawing view '" & oDWGView.Name & "'") Catch ex As Exception MsgBox("The object is not a DV* object") End Try End If End SubEnd Class

 

Posted by: Julian Guillo
Post date: 6/18/2009 6:55:30 AM

RE: Simply way to figure out which drawing view a dimension (or any other annotation object) belongs

Thanks Julian! That was exactly the help I needed.

 

Posted by: Mark Nalevanko
Post date: 6/18/2009 8:50:11 AM

RE: Simply way to figure out which drawing view a dimension (or any other annotation object) belongs

Hi,

 

This is a great post and has helped me a lot (I could not understand why there was not a property on the dimension object itself that was a reference to the view that it was attached to). It seems like a really convoluted way of getting the information you require..

 

Anyway, my problem now is that (for my sins), I've tried to do the same in C# rather than VB.

 

I can therefore call GetRelated() and get a com object as a result, but I cannot cast it to the 2D element that would allow me access to the associated drawing view as I don't know what 2D object it is. Has anyone tried this and could share a c# snippet that would allow you to take the oGraphObject as a com object and get the associated view?

 

Many thanks

 

Nick

 

Posted by: nick lawrence
Post date: 7/20/2009 11:37:00 PM