Forum Replies Created

Viewing 15 posts - 1 through 15 (of 45 total)
  • Author
    Posts
  • in reply to: Script to cake copy with link and boolean it #2334

    Matt
    Participant

    See your post on this other forum http://www.eng-tips.com/viewthread.cfm?qid=396184

    in reply to: Product Engineering Optimizer VBA Code? #2313

    Matt
    Participant

    you need to loop through them all and run the. i found this on a french website.

    ODE:

    Sub Launch_optim()

    Dim analysisDocument1 As AnalysisDocument
    Dim selection1 As Selection
    Dim analysisManager1 As AnalysisManager
    Dim analysisModels1 As AnalysisModels

    Set analysisDocument1 = CATIA.ActiveDocument
    Set analysisManager1 = analysisDocument1.Analysis
    ‘checkname = analysisManager1.Name

    Dim optim1 As Optimization

    Set analysisModels1 = analysisManager1.AnalysisModels

    For i = 2 To 12
    Set optim1 = analysisManager1.Relations.Optimizations.Item(i) ‘selecting the optimization function already set up
    ‘checkname = optim1.Name ‘for debugging only, used to verify the name of the optimization currently selected
    ‘ici je voudrais mettre un code du genre : “optim1.run”
    optim1.run
    Next

    End Sub

    http://catiav5.forumactif.org/t1167-lancer-optimisation-a-partir-d-une-macro

    in reply to: Delete Geometrical set and Pockets #2272

    Matt
    Participant

    I replied to this a week ago but it did not post, sorry 🙁

    Geosets are called “HybridBodies” in VBA but in CATIA they are called Geometrical Sets.

    As i mentioned before:
    You can build the string required by selecting ctrl+f on the keyboard and manually building what you want to search for. Add the search to your favorites and you can copy the string and paste it in your code.

    in reply to: CATDrawing, get Dimension Offset #2261

    Matt
    Participant

    I am not exactly sure (haven’t done much with drawings), but what about DrawingDimension.MoveValue? other than that, nothing jumps out at me in the CHM file.

    Attachments:
    in reply to: Delete Geometrical set and Pockets #2260

    Matt
    Participant

    It is very helpful to include any error messages and the line the macro failed on.

    ‘Hopefully you only have a part open or the macro will fail on setting partDocument1
    Dim partDocument1 As PartDocument
    Set partDocument1 = CATIA.ActiveDocument

    ‘You used Name=HybridBody…Name is the actual name of the feature. You want to use Type.
    Set selection1 = partDocument1.Selection
    selection1.Search “Type=HybridBody, all”

    ‘What if there are no geosets in the part? Your Delete method will fail
    If selection1.Count>0 Then
    selection1.Delete
    End if

    You can build the string required by selecting ctrl+f on the keyboard and manually building what you want to search for. Add the search to your favorites and you can copy the string and paste it in your code.

    in reply to: VB Scripting for CATIA V5: Fourth Edition Updates #2179

    Matt
    Participant

    I just saw your last post…I don’t see the 4th edition on Amazon…just the third

    in reply to: Closing drawings #2178

    Matt
    Participant

    That is great Dave, glad I could help.

    in reply to: Closing drawings #2050

    Matt
    Participant

    Do you know what line it is failing on? First, I would remove CATIA.StartCommand “Center Graph” because you really don’t need to do this.

    Concerning your runtime error, You are looping through the number of open documents and closing them as you go. So let’s say there are 10 documents open, you close one, now there are only 9 documents open…but your macro told CATIA to loop through 10 documents…but there isn’t a 10th document. I think this is your problem. Also, sometimes it takes a while to close documents so the macro may be trying to close documents while CATIA is trying to close the first document, the code below won’t solve this but we can probably come up with something if it doesn’t work.

    If you are using VBA I think you can:
    Loop through all the documents and add them to a collection if they are a drawing, then loop through the collection of drawings and close them based on the name.

    If you are not using VBA, there is no collection class in CATScript/catvbs so you would need to use an array.

    I think the name of the window is the same as the name of the document…so it would look something like this in VBA:

    Dim cDrawings As New Collection
    Dim oDrawing as DrawingDocument

    For iDoc = 1 To CATIA.Documents.Count
    CATIA.Documents.Item(iDoc).Activate
    strType = TypeName(CATIA.ActiveDocument)

    Select Case strType

    Case “DrawingDocument”
    cDrawings.Add CATIA.Documents.Item(iDoc)

    End Select
    Next

    For iDoc = 1 to cDrawings.Count
    Set oDrawing = CATIA.Documents.Item(cDrawings.Item(i).Name)
    oDrawing.Close
    next

    in reply to: Measurebetween Parameter #2042

    Matt
    Participant

    I do not know of a way to access Measures in VBA. I looked in the chm and online, couldn’t find anything. I don’t think they are exposed in VBA.

    in reply to: Convert Files from folder except… #2041

    Matt
    Participant

    On the line where I put ‘add code to do what you want, you would need to add your code there. I’m sorry, I don’t know what your code is doing exactly and it looks like it is only a portion of the code.

    I found some of this in the v5 automation chm file, maybe try putting this where I have ‘add code…

    Dim iPartDoc As Document
    Dim sDocPath as String

    For each oFile in oSubfolder
    sDocPath = oFile.Path
    If Instr(sDocPath, “CATPart”) <> 0 or Instr(sDocPath, “CATDrawing”) <> 0 then
    Set iPartDoc = CATIA.Documents.Open(sDocPath)
    End if
    Next


    Matt
    Participant

    Yeah, that should work…here is more info:
    http://www.coe.org/p/fo/st/topic=113&post=16923#p16923


    Matt
    Participant

    You need separate parts. Any change to one of the parts effects all the instances.


    Matt
    Participant

    The chm file says the InWorkObject property “Returns or sets the in work object of the part”. So you might be able to do something like:

    Dim oGeoset as hybridbody
    set oGeoset = oPart.InWorkObject

    in reply to: Create Coordinate Dimension with text #1704

    Matt
    Participant

    3D annotation is not a simple task.

    For starters, to get the coordinates of a point use GetCoordinates to store coordinates in an array.

    ‘Select a point before running macro
    Dim aCoordinates(2) ‘array for point coordinates
    Dim oPoint

    Set oPoint = CATIA.ActiveDocument.Selection.Item(1).Value
    oPoint.GetCoordinates (aCoordinates)

    in reply to: List.add(itemValue As AnyObject) #1703

    Matt
    Participant

    What type of List is this? I cannot find the type List in VBA. Is this a CATIA list that appears under parameters once created?

    To manually add a feature to a CATIA List, you have to select it then select the add button. Maybe try repeating the manual steps in your macro…

    CATIA.ActiveDocument.Selection.Add oFeature
    oList.Add CATIA.ActiveDocument.Selection.Item(1).value
    CATIA.ActiveDocument.Selection.Clear

Viewing 15 posts - 1 through 15 (of 45 total)