Forum Replies Created

Viewing 15 posts - 1 through 15 (of 26 total)
  • Author
    Posts
  • in reply to: rename part in product #2347

    ramzar
    Participant

    Hello dariooliviero, for my macro to work, you need to have a product with part in it. After, you open the propriety of the first item you want to rename then in the second box from the top, you put “-ici-” (you can chage it for whatever word you want by editing the macro). Let me know if it works.

    in reply to: Intersection and add(boolean) #1438

    ramzar
    Participant

    Hi Matt, yes i’m intersection a bolt with a part. The part dont have any holes in it. If you look at the picture, my bolt are a part in an assembly, and in each part, there is “removehole”. This is a body i want to remove in my part under “split”. I dont want to create a function under split with removehole, only do a verification if they intersect. If yes, then i want to create the fonction “add” with “removehole” under “split”. Your idea of copying before is good. I’ll try to do that. I dont know if i can do that from a collection but i’ll try. The idea of measurement is good, i’ll try to do the intersect first and if its not working, then i’ll try it. Thanks, and have a happy christmas!!

    in reply to: Intersection and add(boolean) #1434

    ramzar
    Participant

    Hi matt, yes, at first, i want to do an intersection but i don’t want to create the fonction in the part. If the screw intersect the part, then i want to create a Add in the part (under “split”). I dont think the mesurment would work. I prefer doing an intersect to verify if the bolt is really in the piece or not.

    And about copying the screw in the part before doing an Add, i can try that but for now i dont even know how to just to an intersect without creating the fonction in the part and how to do the Add and create the fonction by the same occasion.

    • This reply was modified 2 years, 11 months ago by  ramzar.
    in reply to: Introduce Yourself #1384

    ramzar
    Participant

    Hi Ian! Welcome to the forum, i’m quite new to macro programming but i hope i’ll be able to answer some of your questions if there is any.

    On a other note, we work in the Same domain, i work in a mold shop (invesment casting) as a catia mold designer!

    in reply to: Activate solid in a part #1383

    ramzar
    Participant

    I finnaly found how to check the active workbench. Here is the code do verify:

    […]
    Dim woid As String ‘workobjectid
    woid = CATIA.GetWorkbenchId
    If woid <> “Assembly” Then
    MsgBox (“Be active in a product”)
    End
    End If

    […]

    in reply to: Activate solid in a part #1372

    ramzar
    Participant

    Yeah that could be a possibility. But from now, it work good, only need to remember to put it in product. If not, because there is too much windows opening, catia fail and close… It appen 1, not 2!!!

    I’ll check for the vb OKCancel message box, i’ll try to figure out how it works and will post my code after.

    in reply to: rename part in product #1371

    ramzar
    Participant

    Hi, sorry for the late reply, i mean that i want my macro to start at a place i decide. Sometime, in my product, i put some part and rename it and after, i put other block at the end and want to rename only those one, i dont want my macro to run from the begining all the time.

    I made a macro that work, that start from where i want. The only thing is that i need to put the word “ici” (french term for “here”) in the description of the part so the macro is looking for the word “ici” and then start renaming every part after (and erasing the work “ici”). Also, i know that in my part i want to rename the “main body” so i made my macro so it rename the part and the main body. So here is my macro, if this could help some people!!!

    Sub CATMain()

    Dim productDocument1 As Document
    Dim product1 As Product
    Dim products1 As Products
    Dim partdoc As partdocument
    Dim partdocument As Document
    Dim part As part
    Dim partproduct As Product
    Dim bodies1 As AnyObject
    Dim counter As Integer

    Set productDocument1 = CATIA.ActiveDocument
    Set product1 = productDocument1.Product
    Set products1 = product1.Products

    counter = 1

    ‘count the number of CATParts within the catproduct
    partcount = products1.Count

    Dim Namer As String
    Namer = InputBox(“Put SOB name.”, “Préfixe”, “SOB-XXXX”)

    Dim Namer2 As Integer
    Namer2 = InputBox(“Put the start number.”, “Numéro de départ”, “1”)

    Dim i As Integer
    ‘loop through all parts to find the place to begin renaming
    For i = 1 To partcount

    Dim getdes3 As String
    getdes3 = products1.Item(i).DescriptionInst
    If getdes3 = “ici” Then
    counter = 0
    products1.Item(i).DescriptionInst = “”

    Dim k As Integer
    ‘loop through all parts
    For k = i To partcount

    Set partproduct = products1.Item(k)

    ‘apply design mode to each part
    products1.Item(k).ApplyWorkMode DESIGN_MODE

    Dim getDes, getDes2 As String
    getDes = products1.Item(k).PartNumber
    getDes2 = products1.Item(k).Name

    products1.Item(k).PartNumber = Namer & Namer2
    products1.Item(k).Name = Namer & Namer2

    Set partdocument = partproduct.ReferenceProduct.Parent
    Set part = partdocument.part
    Set bodies1 = part.MainBody

    bodies1.Name = Namer2

    Namer2 = Namer2 + 1

    Next ‘k
    End
    End If

    Next ‘i
    If counter = 1 Then
    MsgBox (“Put -ici- in a part”)
    End
    End If
    End Sub

    in reply to: rename part in product #1365

    ramzar
    Participant

    ok i change my macro again! and now it work well. My only concern is that i want to replace “namer3” inputbox by a selection of the line i want to start renaming my part. But i didnt find any way to know at witch line my selection is in “partcount” Any ideas?

    Sub CATMain()

    Dim productDocument1 As Document
    Dim product1 As Product
    Dim products1 As Products
    Dim selection As selection

    Set productDocument1 = CATIA.ActiveDocument
    Set product1 = productDocument1.Product
    Set products1 = product1.Products
    Set selection = CATIA.ActiveDocument.selection

    ‘count the number of CATParts within the catproduct
    partcount = products1.Count

    Dim Namer As String
    Namer = InputBox(“Put SOB name.”, “Préfixe”, “SOB-XXXX”)

    Dim Namer2 As Integer
    Namer2 = InputBox(“Put the start number.”, “Numéro de départ”, “1”)

    Dim namer3 As Integer
    namer3 = InputBox(“Put the number relative to the begining line”, “Line start”, “1”)

    Dim i As Integer

    ‘loop through all parts
    For i = namer3 To partcount

    ‘apply design mode to each part
    products1.Item(i).ApplyWorkMode DESIGN_MODE

    Dim getDes, getDes2 As String
    getDes = products1.Item(i).PartNumber
    getDes2 = products1.Item(i).Name

    products1.Item(i).PartNumber = Namer & Namer2
    products1.Item(i).Name = Namer & Namer2

    Namer2 = Namer2 + 1

    Next ‘i

    End Sub

    in reply to: rename part in product #1360

    ramzar
    Participant

    Here is my new code with a selection in, instead of renaming all the parts in the assembly.

    Sub CATMain()

    Dim productDocument1 As Document
    Dim product1 As Product
    Dim products1 As Products
    Dim selection As selection

    Set productDocument1 = CATIA.ActiveDocument
    Set product1 = productDocument1.Product
    Set products1 = product1.Products
    Set selection = CATIA.ActiveDocument.selection

    ‘count the number of CATParts within the catproduct
    partcount = selection.Count
    MsgBox (“The number of part is ” & partcount)

    If selection.Count = 0 Then
    MsgBox (“Sélectionner les parts à renommer et relancer la macro.”)
    End
    End If

    Dim Namer As String
    Namer = InputBox(“Put SOB name.”, “Préfixe”, “SOB-XXXX”)

    Dim Namer2 As Integer
    Namer2 = InputBox(“Put the start number.”, “Numéro de départ”, “1”)

    Dim i As Integer

    ‘Loop through all parts
    For i = 1 To partcount

    ‘apply design mode to each part
    selection.Item(i).ApplyWorkMode DESIGN_MODE <——Error here

    Dim getDes, getDes2 As String
    getDes = selection.Item(i).PartNumber <—-Here too
    getDes2 = selection.Item(i).Name <—-Here too

    partDoc1.PartNumber = Namer & i
    partDoc1.Name = Namer & i

    Namer2 = Namer2 + 1

    Next ‘i
    End Sub

    in reply to: rename part in product #1359

    ramzar
    Participant

    Yep, exactly

    in reply to: Activate solid in a part #1358

    ramzar
    Participant

    I have a product, and in it, i have alot of part. I want to check if i’m in the product before starting the macro because in the macro, i change workbench and if i start the macro while being in part, it open x number of part and product, where x is the number of part in my assembly.

    in reply to: rename part in product #1327

    ramzar
    Participant

    I’m in catvba. Can i get collection in catvba?

    And i try namer=namer+1 and the + symbol disapear after i put it.

    in reply to: Activate solid in a part #1326

    ramzar
    Participant

    i try “If UCase(TypeName(CATIA.ActiveDocument)) <> “PRODUCTDOCUMENT) Then
    MsgBox “You must load a product, exiting macro”
    Exit sub
    end If”
    I didnt work. I change “PRODUCTDOCUMENT” for “CATPRODUCT” and didn’t work either.

    And now the macro dont work with:
    ‘bIsInactive = oPart.IsInactive(oShape)
    ‘If bIsInactive = True Then
    So i just put a ‘ and know its ok.

    in reply to: Activate solid in a part #1313

    ramzar
    Participant

    Hi Matt, thanks for your last answer it work perfectly. And for the problem with my macro at “Activate” i found that to write it good, it was like this:”oPart.Activate oShape” instead of :”oPart.Activate (oShape).

    I don’t know why… i searched in the help and normally, we are supposed to write “oshape” with(). But now it works!!! the only thing is to verify if im in product because if i’m in a part, because we change workbench. it start a new product, then start a new part, then a product, etc and it goes all over the tree like this so with 100+ part…… it open alot and catia close. I try the line you send me before but it didn’t work.

    For all your help, seriously, i cant thank you enough. Thank you!Thank you! Thank you!

    in reply to: Activate solid in a part #1283

    ramzar
    Participant

    I just try to use the macro on another job and it don’t work. I go step by step trying to see where it don’t work and it seems that even if the macro read that “Solide.42” is Inactivate, it skip the activate line and go next.

    Also, i just realize that at the end of my tree, i have a product containing screws. My macro fails when it get there at this line: “Set oPart = oPartDocument.Part”. Is there any way to control if it’s a part or a product, and then skip the product?

    Thank you!

    • This reply was modified 3 years ago by  ramzar.
Viewing 15 posts - 1 through 15 (of 26 total)