×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

(OP)
Hi friends,

Am new to this forum...

i heard about this forum through my frnds.

happy to be part of this forum.

I need a macro very urgently to extract the dimensions near to the Instantiate 2D component symbols in CatiaV5 drawing and save/export those dimensions to an excell file.

am using Catia V5 R19....

Please do the needful...

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

@friendlyamu
Are you referring to the dimensions that can be found by right-clicking the component instance in the tree and clicking on Properties and looking under the 2D Component Instance tab? See attached image for clarification.

If yes, then you can use the following code. I will need you to respond and clarify what sheet and view the instance is located on. Also, where and under what name do you want the excel file to be saved? Right now, this code simply outputs it via a message box.

CODE --> vba

Sub CATMain()

Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument

Dim drawingSheets1 As DrawingSheets
Set drawingSheets1 = drawingDocument1.Sheets

Dim drawingSheet1 As DrawingSheet
Set drawingSheet1 = drawingSheets1.Item("Sheet.1")

Dim drawingViews1 As DrawingViews
Set drawingViews1 = drawingSheet1.Views

Dim drawingView1 As DrawingView
Set drawingView1 = drawingViews1.Item("Front view")

Dim drawingComponents1 As DrawingComponents
Set drawingComponents1 = drawingView1.Components

Dim drawingComponent1 As DrawingComponent
Set drawingComponent1 = drawingComponents1.Item("Detail.1.1")

MsgBox "X: " & Round(drawingComponent1.X / 25.4, 2) & vbCr & "Y: " & Round(drawingComponent1.Y / 25.4, 2)

End Sub 

Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

(OP)
Hi drewmumaw,

Thank you so much for your reply.

Sorry for not mentioned my requirements clearly in my previous thread.

My requirements are,I need a Macro which can export the list of dimensions containing the symbol adjacent to that & save as an excel (or) csv file.

The excel (or) csv file has to be saved in Drawing name and in the folder which contains the respective Catia V5 drawing.

Please see the attached image for clarification...








RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

@friendlyamu
I understand. So you want to export to a .csv file with all of the dimensions that have a specific symbol next to them, correct? If yes, then my answer is, this cannot be done as you would like unless there's something else (possibly the naming of the dimensions?) that differentiates the dimensions with the symbols from the dimensions without the symbols. It's possible to export all of the dimensions on Sheet.1, but from your screen grab, I don't see how the macro would be able to tell which dims have a symbol associated and which ones don't. There would have to be some manual work after the fact. Or, like I mentioned, if the dimensions with the symbols have something special in their name such as "dimwithsymbol" then the macro could just export those. For example, a dimension with a symbol could be named "Dimension.4.dimwithsymbol" and the script would sort through all of the dims and include this one for export since it had the "dimwithsymbol" string in the name.

I put this macro together quickly to show you how to loop through all of the dims in each of the views on "Sheet.1". It just shows them in a message box pop up one at a time. It doesn't process angles correctly and doesn't have a way of telling dims with symbols apart from the dims without symbols:

CODE --> vba

Sub CATMain()

Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.ActiveDocument

Dim drawingSheets1 As DrawingSheets
Set drawingSheets1 = drawingDocument1.Sheets

Dim drawingSheet1 As DrawingSheet
Set drawingSheet1 = drawingSheets1.Item("Sheet.1")

Dim drawingViews1 As DrawingViews
Set drawingViews1 = drawingSheet1.Views

For ctrViews = 1 To drawingViews1.Count

    Dim drawingDimensions1 As DrawingDimensions
    Set drawingDimensions1 = drawingViews1.Item(ctrViews)
    
    For ctrDims = 1 To drawingDimensions1.Count
    
        MsgBox drawingDimensions1.Item(ctrDims).GetValue.Value
    
    Next ctrDims

Next ctrViews

End Sub 

Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

(OP)
Hi drewmumaw

The screen grab which I have attached in my previous thread was just an example. My Drawing may contain ‘N’ number of views (see the ‘Specification Tree’ for the drawing - REV003 in the image attached in my previous thread) and ‘N’ number of dimensions with the symbols and without the symbols in the views.

I dont understand what do you mean by dimension with a symbol could be named "Dimension.4.dimwithsymbol".Did you mean that each dimension with symbol should have an unique TEXT before?

Is it possible to sort and export the dimensions based on the Name given for the ‘Instantiate 2D component” symbol in the Drawing sheet? (For example TRIANGLE_3 (or) DIAMOND) ( Refer attached image)

And I don't want any message box pop up to show the dimensions in the views, thats not my requirement.

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

Hi,

@ friendlyamu - be so kind and post what you tried to code to solve your requirements, it will be much easier for others to help you. If you want to learn more about programming first you should try something, don't expect for others to solve your problems completely, what you want is not so easy to be done (and by the way, it can be achieved only if your drawing was done in a specific way, meaning dimension has a link with the ditto, otherwise is to complicated and is wasting developer's time).

Generally speaking, when someone develop a macro for his company (or for himself), is taking in account how often it will be used and how big it will be the benefits using the macro comparing with time to develop that macro.

Regards
Fernando

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

@friendlyamu
The code I uploaded was labeled "vba". According to your screen grab 2Que, it looks like you were trying to test it in a vbscript editor with different syntax. That could possibly be causing the error you mentioned. To test it in CATIA's built in vba editor hit Alt+F11 or simply go to Tools > Macros > Visual Basic Editor. Create a new catvba file if one doesn't already exist. In the left hand side, right-click on the catvba file and insert a new module. See this image. You can put your code in here and run it by clicking the rightward facing arrow that looks like a play button.

Also, I'm aware that the code I uploaded did not solve your requirements, it was simply a starting off point for getting the logic structure together for your eventual solution - as I mentioned in my first post:

Quote (drewmumaw)

I put this macro together quickly to show you how to loop through all of the dims in each of the views on "Sheet.1". It just shows them in a message box pop up one at a time. It doesn't process angles correctly and doesn't have a way of telling dims with symbols apart from the dims without symbols
Right now I simply use message boxes to view what could be output to a .csv - since I'm 100% sure that exporting to a .csv is possible I didn't waste any time including it in the logic. In other words, we can add that requirement last.

Thanks for the screen grabs. They are very helpful.

Quote (friendlyamu)

Is it possible to sort and export the dimensions based on the Name given for the ‘Instantiate 2D component” symbol in the Drawing sheet? (For example TRIANGLE_3 (or) DIAMOND) ( Refer attached image)
No. The name of the "Instantiate 2Dcomponent" is not relevant from an automation standpoint. We need a way to determine which dimensions have a symbol next to them and which ones don't.

Quote (friendlyamu)

I dont understand what do you mean by dimension with a symbol could be named "Dimension.4.dimwithsymbol".Did you mean that each dimension with symbol should have an unique TEXT before?
Yes. If it's feasible from your side of things - something along those lines would work. See this image as just an example of how the dimensions with the symbol could be named. If they all had some string of text in their name, such as "dimwithsymbol" or whatever else, then the macro would be able to know which dimensions need to be exported and which ones don't.

Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

(OP)
Hi drewmumaw, as I was away from work I couldn't reply immediately. I need your help in knowing the coding for exporting a selected set of dimensions from Catia V5 drawing to Excel. I'm not a programmer. So only with your support, I can accomplish this task.

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

@friendlyamu
This code will write your selected dimension values to a .csv file on the desktop (you need to change the file path in the code to reference your desktop location - not mine). See here for an example of the output.

CODE --> vba

Sub CATMain()

    Dim oDwgDoc1 As DrawingDocument
    Set oDwgDoc1 = CATIA.ActiveDocument
    
    Dim oSel As Selection
    Set oSel = oDwgDoc1.Selection
    
    If oSel.Count < 1 Then
        MsgBox ("No dimensions selected."), vbExclamation
        End
    End If
    
    Dim oDwgDim As DrawingDimension
    Dim oInt As Integer
    Dim dblDims() As Double
    
    For ctr = 1 To oSel.Count
        Set oDwgDim = oSel.Item(ctr).Value
        ReDim Preserve dblDims(ctr - 1)
        dblDims(ctr - 1) = oDwgDim.GetValue.Value
    Next
    
    Dim strFilePath As String
    Dim objFSO As Object
    Dim objStream As Object
    
    strFilePath = "C:\Users\Drew\Desktop\dimensions.csv"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objStream = objFSO.OpenTextFile(strFilePath, 8, True, 0)
    
    For i = 1 To oSel.Count
        objStream.WriteLine (dblDims(i - 1))
    Next

End Sub 

Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

(OP)
Hi drewmumaw,

The code works great. Thanks a lot for your help.

This code exports the selected dimension to the Excel file superbly.

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

(OP)
Hi drewmumaw, The code exports the nominal value of selected dimensions as .csv but ignores to take it's tolerance value. What should be done for accomplishing this ? Also I would like to know is it possible to export some selected Geometrical Tolerances (Say Flatness, Position etc.,) along with value in the feature control frame to .csv ?

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

@friendlyamu
The code below will also export the tolerance values. I'm not sure about the geometrical tolerances.

CODE --> vba

Sub CATMain()

    Dim oDwgDoc1 As DrawingDocument
    Set oDwgDoc1 = CATIA.ActiveDocument
    
    Dim oSel As Selection
    Set oSel = oDwgDoc1.Selection
    
    If oSel.Count < 1 Then
        MsgBox ("No dimensions selected."), vbExclamation
        End
    End If

    Dim oDwgDim As DrawingDimension
    Dim oInt As Integer
    Dim dblDims() As Double
    
    Dim oTolType As Long
    Dim oTolName As String
    Dim oUpTol As String
    Dim oLowTol As String
    Dim odUpTol As Double
    Dim odLowTol As Double
    Dim oDisplayMode As Long
    
    For ctr = 1 To oSel.Count
        Set oDwgDim = oSel.Item(ctr).Value
        ReDim Preserve dblDims(2, ctr - 1)
        dblDims(0, ctr - 1) = oDwgDim.GetValue.Value
        oDwgDim.GetTolerances oTolType, oTolName, oUpTol, oLowTol, odUpTol, odLowTol, oDisplayMode
        dblDims(1, ctr - 1) = odUpTol
        dblDims(2, ctr - 1) = odLowTol
    Next
    
    Dim strFilePath As String
    Dim objFSO As Object
    Dim objStream As Object
    
    strFilePath = "C:\Users\Drew\Desktop\dimensions.csv"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objStream = objFSO.OpenTextFile(strFilePath, 8, True, 0)
    
    For i = 1 To oSel.Count
        objStream.WriteLine (dblDims(0, i - 1) & "," & dblDims(1, i - 1) & "," & dblDims(2, i - 1))
    Next
    
End Sub 

Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

Hi,

Geometrical tolerances were not exposed to automation.
There is no API of any kind to access, using object browser also wont yield any results.
Tried some times back with no success

Regards,
Maddy

The willingness to share knowledge does not make one charitable; it makes one self-reliant to know more.
Modified - Courtesy of Robert Brault

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

(OP)
Hi drewmumaw, code works fine. After running the code I observed the following things,.. 1) Code extract and transfer the Angle value in the drawing as Radian value in the Excel(csv) sheet, 2) For Chamfer dimensions (say, 5*45 deg) code extracts only the 'length' 5 to the excel sheet, 3) Also the tolerance value of the previous listed nominal dimension is taken for the following Angle/Chamfer dimension even though no tolerance is assigned to them. (Refer attached image).

@Maddy02 : Thank a lot for your valuable information.

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

@friendlyamu
This should take care of the tolerance values and radians:

CODE --> vba

Sub CATMain()

    Dim oDwgDoc1 As DrawingDocument
    Set oDwgDoc1 = CATIA.ActiveDocument
    
    Dim oSel As Selection
    Set oSel = oDwgDoc1.Selection
    
    If oSel.Count < 1 Then
        MsgBox ("No dimensions selected."), vbExclamation
        End
    End If

    Dim oDwgDim As DrawingDimension
    Dim oInt As Integer
    Dim dblDims() As Double
    
    Dim oTolType As Long
    Dim oTolName As String
    Dim oUpTol As String
    Dim oLowTol As String
    Dim odUpTol As Double
    Dim odLowTol As Double
    Dim oDisplayMode As Long
    
    For ctr = 1 To oSel.Count
        Set oDwgDim = oSel.Item(ctr).Value
        ReDim Preserve dblDims(2, ctr - 1)
        If oDwgDim.DimType = catDimAngle Then
            dblDims(0, ctr - 1) = oDwgDim.GetValue.Value * 57.2957795
        Else
            dblDims(0, ctr - 1) = oDwgDim.GetValue.Value
        End If
        oDwgDim.GetTolerances oTolType, oTolName, oUpTol, oLowTol, odUpTol, odLowTol, oDisplayMode
        dblDims(1, ctr - 1) = odUpTol
        dblDims(2, ctr - 1) = odLowTol
        odUpTol = 0
        odLowTol = 0
    Next
    
    Dim strFilePath As String
    Dim objFSO As Object
    Dim objStream As Object
    
    strFilePath = "C:\Users\Drew\Desktop\dimensions.csv"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objStream = objFSO.OpenTextFile(strFilePath, 8, True, 0)
    
    For i = 1 To oSel.Count
        objStream.WriteLine (dblDims(0, i - 1) & "," & dblDims(1, i - 1) & "," & dblDims(2, i - 1))
    Next

    objStream.Close

End Sub 

Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

Hi,

My requirement is also same that of what friendlyamu posted.But i want to extract some more details to the csv file.

Is it possible to extract the Balloon numbers along with the corresponding dimensions in the extracted csv file?

Please find the image for better understanding.

Thanks in advance.

Regards,

D.Balaji

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

(OP)
Hi drewmumaw, Code works great except that it doesn't transfer the Angle value in the Chamfer dimension. Is it possible to fix this ? Thanks for your help.

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

@friendlyamu
I looked, but couldn't find anything in the API for being able to do this. If you put the chamfer dimension in the format angle x distance then it will export the angle, but not the distance. Apparently, you can only access the first value in a chamfer dimension. This seems odd, so I'll keep looking through the API, but I tried several things already and couldn't find a way to access it. Maybe someone else will post a way that this can be done? But from my initial web searches and other threads it seems like automation in the drafting workbench is very restrictive.

@DBalaji89
Yes. It is possible to extract the balloon numbers. However, there must be something for the script to be able to know that the balloon is related to the dimension. Either the balloon should have a positional link (see this) with it's corresponding dimension, or the name of the dimension and the balloon should have a string in both that relates the two. For example, the name of the dimension could be DimensionWithBalloon.5 and the name of the name of the balloon could be Balloon.5. That way the script would know to look for a dimension and a balloon with the name Balloon.5 in them so that it could export them on the same line in the .csv file. I would recommend doing it with the positional link.

Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

@drewmumaw
First of all i would like to say thanks for your reply.

To be frank, am not a programmer and I don't have any knowledge in writing code in VB.I just suggested to enhance Friendlyamu's requirement.

As per your last code it exports only selected set of dimensions to csv file.In case if the selected set of dimensions(selected from different VIEWS in the drawing) contain a similar dimensions it would be difficult to identify in the csv file that which dimension from which VIEW (or) ZONE in the drawing is exported.

So I requested, Is it possible to extract the Balloon numbers along with the corresponding dimensions in the extracted csv file?

It will be great if you can post the code that can extract Balloon numbers(having positional link with the dimension) along with the dimensions.

Thanks in advance.

Regards,

D.Balaji


RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

(OP)
Hi drewmumaw,understood from your reply that it is difficult to retrieve angle value in a Chamfer dimension. Please update once you get some success in this regard. But after running the code for a Chamfer dimension in the format Angle x Distance in a drawing,Code exports (only) the Angle value as Radian value to the .csv file. All other Angle values in the drawings are coming perfectly.Is it possible to fix this ?
With regards to DBalaji89's suggestion, it is definitely necessary to have some way to identify the dimension extracted in the .csv file. This way of giving balloon number & extracting it along with the corresponding dimension in the same line in the .csv is highly appreciated.Also it would be very helpful to accomplish my task if you can post the code that exports balloon numbers along with the dimension.

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

@DBalaji89
If you want the script to output the corresponding view that the dimension is located within use this:

CODE --> vba

Sub CATMain()
    
    Dim oDwgDoc1 As DrawingDocument
    
    On Error Resume Next
        Set oDwgDoc1 = CATIA.ActiveDocument
        If Err.Number <> 0 Then
            MsgBox ("The active document must be a drawing."), vbExclamation
            End
        End If
    On Error GoTo 0
    
    Dim oSel As Selection
    Set oSel = oDwgDoc1.Selection
    
    If oSel.Count < 1 Then
        MsgBox ("No dimensions selected."), vbExclamation
        End
    End If

    Dim oDwgDim As DrawingDimension
    Dim oInt As Integer
    Dim dblDims()
    
    Dim oTolType As Long
    Dim oTolName As String
    Dim oUpTol As String
    Dim oLowTol As String
    Dim odUpTol As Double
    Dim odLowTol As Double
    Dim oDisplayMode As Long
    
    For ctr = 1 To oSel.Count
        
        On Error Resume Next
            Set oDwgDim = oSel.Item(ctr).Value
            If Err.Number <> 0 Then
                MsgBox ("One of the selected elements is not a drawing dimension."), vbExclamation
                End
            End If
        On Error GoTo 0
        
        ReDim Preserve dblDims(3, ctr - 1)
        If oDwgDim.DimType = catDimAngle Then
            dblDims(0, ctr - 1) = oDwgDim.GetValue.Value * 57.2957795
        Else
            dblDims(0, ctr - 1) = oDwgDim.GetValue.Value
        End If
        oDwgDim.GetTolerances oTolType, oTolName, oUpTol, oLowTol, odUpTol, odLowTol, oDisplayMode
        dblDims(1, ctr - 1) = odUpTol
        dblDims(2, ctr - 1) = odLowTol
        dblDims(3, ctr - 1) = oDwgDim.Parent.Parent.Name
        odUpTol = 0
        odLowTol = 0
        
    Next
    
    Dim strFilePath As String
    Dim objFSO As Object
    Dim objStream As Object
    
    strFilePath = "C:\Users\Drew\Desktop\dimensions.csv"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objStream = objFSO.OpenTextFile(strFilePath, 8, True, 0)
    
    For i = 1 To oSel.Count
        objStream.WriteLine (dblDims(0, i - 1) & "," & dblDims(1, i - 1) & "," & dblDims(2, i - 1) & "," & dblDims(3, i - 1))
    Next

    objStream.Close

End Sub 

Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

@friendlyamu
I just saw your response after my browser refreshed. Hopefully the code I just posted for exporting the view name will suffice for locating the dimension.

Also, with regards to this:

Quote (friendlyamu)

after running the code for a Chamfer dimension in the format Angle x Distance in a drawing,Code exports (only) the Angle value as Radian value to the .csv file. All other Angle values in the drawings are coming perfectly.Is it possible to fix this ?

Yes. It is possible to fix this, but all of your chamfer dimensions must be in the same format - either angle x distance or distance x angle. They can't be a mix of the two because there's no way that I've found in the API to grab the second dimension. So either it will export the angle (in degrees) if it's in the format angle x distance or the distance if it's in the format distance x angle.

Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

(OP)
Hi Drewmumaw,code works excellent. Code exports the selected Dimensions with Tolerances(if available)along with the VIEW name. Further I need your support on the following 2 points, 1)How about the earlier case that we discussed for extracting the balloon numbers (having positional link) along with the corresponding dimensions & put them in the same line. Can you provide the code for this ? 2) Also as per your suggestion, we will follow a consistency in providing the Chamfer dimension format as "angle x distance". So please help us in extracting the angle value for the Chamfer dimension in degrees (which is getting extracted as Radians as of now). Thanks for your constant support in this regard.

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

@friendlyamu
1. It's possible to extract the associated balloons, but it would require a loop to get all of the balloon's associated elements and then check to see if the associated element's dimension is getting exported. If it is, then it would also export that balloon's value. Long story short, it requires a lot more code, but would include the AssociateElement property:

CODE --> vba

Dim oBalloon As DrawingText
Set oBalloon = drawingTexts1.GetItem("Balloon.1")

oBalloon.AssociativeElement 

2. If you have all chamfers in the format angle x distance then give this code a try. It should export the angle in degrees instead of radians.

CODE --> vba

Sub CATMain()
    
    Dim oDwgDoc1 As DrawingDocument
    
    On Error Resume Next
        Set oDwgDoc1 = CATIA.ActiveDocument
        If Err.Number <> 0 Then
            MsgBox ("The active document must be a drawing."), vbExclamation
            End
        End If
    On Error GoTo 0
    
    Dim oSel As Selection
    Set oSel = oDwgDoc1.Selection
    
    If oSel.Count < 1 Then
        MsgBox ("No dimensions selected."), vbExclamation
        End
    End If
    
    Dim oDwgDim As DrawingDimension
    Dim oInt As Integer
    Dim dblDims()
    
    Dim oTolType As Long
    Dim oTolName As String
    Dim oUpTol As String
    Dim oLowTol As String
    Dim odUpTol As Double
    Dim odLowTol As Double
    Dim oDisplayMode As Long
    
    For ctr = 1 To oSel.Count
        
        On Error Resume Next
            Set oDwgDim = oSel.Item(ctr).Value
            If Err.Number <> 0 Then
                MsgBox ("One of the selected elements is not a drawing dimension."), vbExclamation
                End
            End If
        On Error GoTo 0
        
        ReDim Preserve dblDims(3, ctr - 1)
        If oDwgDim.DimType = catDimAngle Or oDwgDim.DimType = catDimChamfer Then
            dblDims(0, ctr - 1) = oDwgDim.GetValue.Value * 57.2957795
        Else
            dblDims(0, ctr - 1) = oDwgDim.GetValue.Value
        End If
        oDwgDim.GetTolerances oTolType, oTolName, oUpTol, oLowTol, odUpTol, odLowTol, oDisplayMode
        dblDims(1, ctr - 1) = odUpTol
        dblDims(2, ctr - 1) = odLowTol
        dblDims(3, ctr - 1) = oDwgDim.Parent.Parent.Name
        odUpTol = 0
        odLowTol = 0
        
    Next
    
    Dim strFilePath As String
    Dim objFSO As Object
    Dim objStream As Object
    
    strFilePath = "C:\Users\Drew\Desktop\dimensions.csv"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objStream = objFSO.OpenTextFile(strFilePath, 8, True, 0)
    
    For i = 1 To oSel.Count
        objStream.WriteLine (dblDims(0, i - 1) & "," & dblDims(1, i - 1) & "," & dblDims(2, i - 1) & "," & dblDims(3, i - 1))
    Next

    objStream.Close

End Sub 

Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

(OP)
Hi drewmumaw, code works great. Thanks a lot for your help and support.

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

Dear all,

Great work, I found this macro. But we have lot of problems with VBA, if possible could you translate it to catscript or catvbs format with balloon function?

regards,
Catia user/looser :)

RE: Macro to extract dimensions related to Instantiate 2D symbol in catia drawing & export them in e

Hello All

May I ask refering to my question http://www.eng-tips.com/viewthread.cfm?qid=358168 , is the same procedure possible to get the data to be edited in Excel from a partbody instead of a drawing ?

what are the apropriate modifications ?

Thank you very much

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Engineering as It Should Be - Chapter 2: Document Security
This ebook covers basic tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Chapter 2 covers cybersecurity and answers the question: How do you secure your files and documents? Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close