Drawing dimension

Drawing dimension

kv5053545
Advocate Advocate
638 Views
5 Replies
Message 1 of 6

Drawing dimension

kv5053545
Advocate
Advocate
Sub main()
   
    Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument 
    Dim oActiveSheet As Sheet = oDoc.ActiveSheet 

   
    For Each oDrawingView As DrawingView In oActiveSheet.DrawingViews 
       
        If oDrawingView.Name = "VIEW6" Then
            Dim oRefDoc As AssemblyDocument = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument 
            Dim oAssDef As AssemblyComponentDefinition = oRefDoc.ComponentDefinition 

            Dim oOcc As ComponentOccurrence
            For Each oOcc In oAssDef.Occurrences 
                Dim oSubOcc As ComponentOccurrence
                For Each oSubOcc In oOcc.SubOccurrences 
                    Dim componente As String = oSubOcc.Name 
                 If componente.Contains("Gaskets:1") Then   
				       MessageBox.Show(componente) 

                  
                    Dim oSubSubOcc As ComponentOccurrence 
                    For Each oSubSubOcc In oSubOcc.SubOccurrences
                        Dim subComponente As String = oSubSubOcc.Name 
                       
						If subComponente.Contains("Gasket:1") Then
							 MessageBox.Show(subComponente) 
							  Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("Sheet:1") 
                        Dim VIEW6 = Sheet_1.DrawingViews.ItemByName("VIEW6") 
              
                        Dim namedGeometry1 = VIEW6.GetIntent(subComponente,"WP_GasketTop")
                        Dim namedGeometry2 = VIEW6.GetIntent(subComponente, "WP_GasketBottom")
                        Dim genDims = Sheet_1.DrawingDimensions.GeneralDimensions 
                        Dim dimX = -0.02 
                        Dim dimY = -0.02 
                        Dim linDim1 = genDims.AddLinear("Dimension 1" & componente, VIEW6.SheetPoint(dimX, dimY), namedGeometry1, namedGeometry2) 

						End If 
                    Next
		
				
				End If

                Next
            Next
        End If
    Next
End Sub

I have this code to generate dimensions in a drawing but I have this error
GetIntent("Gasket:1", "WP_GasketTop"): The component named "Gasket:1" was not found, what I don't understand is why it doesn't find the component if in a previous if it finds it.
I don't know if there is something I'm not seeing right in the code, I would appreciate your help!

 

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

A.Acheson
Mentor
Mentor

Hi @kv5053545 

Can you confirm what error message your getting and which line the code errors out on?

Also are you sure the occurrence name is an acceptable argument for the Get Intent method. Help page shown here

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

cadconfigurator
Participant
Participant

Is it possibly a typo? Gaskets:1 <--> Gasket:1  

Message 4 of 6

kv5053545
Advocate
Advocate

Hi @A.Acheson, This is the error that appears in line 29, as far as I understand it is a value that accepts the GetIntent

kv5053545_0-1720450415244.png

This is how it appears in the model:

kv5053545_1-1720450665975.png

 

 

0 Likes
Message 5 of 6

WCrihfield
Mentor
Mentor
Accepted solution

Hi @kv5053545.  It looks like your spelling and capitalization are correct, however, since that component is within a sub assembly, you need to specify more than just its name.  You need to specify the 'Path' of that component.  The path is an Array of Strings, starting with the name of the top level component that represents the sub assembly, then the name of the component within that sub assembly.

When you look at the online documentation for IManagedDrawingView.GetIntent Method (there are two versions of this method, the other one is at this link), you will see that the first 'input' being requested is called a ComponentArgument.  This 'type' of object is odd, because it can be specified with a single String (the name of a component, if it is top level), or an Array of Strings (if it is a component within a sub assembly), or an IManagedComponentOccurrence object.  In your case, it would be the second option.  Similar to the MakePath iLogic tool, but I don't think it is looking for that tool here.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 6

kv5053545
Advocate
Advocate
Hi, Thank you very much it was just what I needed
0 Likes