Forum Replies Created
Option Explicit forces you to declare (Dim) every variable. You would need to Dim sketch1 in order to avoid the failure with Option Explicit on.
I don’t see it either, maybe try making a small code to see if there is a typename of the reuse pattern. if it has a type name, search for it in the help document.
‘Select the reuse pattern then tun this macro to see the typename
‘of the pattern in your VBA immediate window
‘Sets user name to the user logged in to the network on this computer
Dim sUser As String
Set oNetwork = CreateObject(“WScript.Network”)
sUser = oNetwork.UserName
Dim oFSO ‘As FileSystemObject ‘File System Object grants access to computer files and folders
Dim sSourceFolder As String
Set oFSO = CreateObject(“Scripting.FileSystemObject”) ‘File System Object grants access to computer files and folders
sSourceFolder = “C:\Users\” & sUser & “\Desktop\MainFolder” ‘Set the source folder where usage files were stored
Set oSourceFolder = oFSO.GetFolder(sSourceFolder) ‘Tell File System Object to get a hold of oSourceFolder so you can look into it
‘Loop through folders unless they have a specific name
For Each oSubFolder In oSourceFolder.SubFolders
If oSubFolder.Name = “BUY-PARTS” Or oSubFolder.Name = “CUSTOMER-PARTS” Then
‘add code to do what you want
It will be easier to measure because you will not need to paste the bolts into the part to create the intersect. Use the SPA workbench to make measurements.
So you are intersecting a part with a bolt…the part does not have a hole for the bolt to pass through?
You cannot create geometry outside of a part. So if you want to make an intersect between the bolt and the part, both of the features (the bolt and the part) need to exist in the same part and an intersect needs to be created.
If there is no hole where the bolt will pass through, take a measurement between the bolt and the part. If the distance = 0, you know they intersect.December 14, 2014 at 1:45 pm in reply to: How to get CATIA VBAScript to answer a "Ok", "Apply" and "Cancel" Window #1432
Unfortunately, send keys is the only way to do this in VB and it does not work very well…if it works at all.
I’m sorry, I’m a little confused. Are you intersecting the bolt to the part? Could you do something that does not require the creation of geometry…like measure from the bolt centerline to the center point of the attachment hole?
If the distance is 0mm you would need to copy the body for that bolt and paste it into the part.
There are a few ways to do it. Would you be able to post your code so we can see what you tried?
Below loops through the Product’s parameters until it finds the one you want, then changes the value.
Dim oRootProduct as Product
Dim oParameters as Parameters
Dim oParameter as Parameter
For I = 1 to oParameters.Count
If instr(ucase(oParameters.item(i).Name), “NAZEV”) <> 0 then
Set oParameter = oParameters.Item(I)
oParameter.Value = “YourValue”
You can also find the parameter by name instead of looping. I think the name of the parameter is actually the path.
On Error Resume Next
oParameter = oParameters.Item(oRootProduct.Name & “\” & “Nazev”)
If err.number <> 0 then
Msgbox “Parameter does not exist”
oParameter.Value = “YourValue”
On error GoTo 0
Are you writing a macro to change the value of the parameter in the assembly?
What did the error say? CATScript is similar to VBA but it doesn’t have all the functionality of VBA.
This is VBScript versus VBA http://msdn.microsoft.com/en-us/library/ms970436.aspxNovember 20, 2014 at 12:38 am in reply to: VBScript to collect the names of douments opened in Multiple CATIA Sessions. #1391
Are you saying you will launch catia multiple times and load assemblies in to each session of CATIA?
catia will be launched once and several assemblies will be loaded into ONE session of CATIA?
If you are launching multiple catia sessions (not sure why you would want to occupy multiple licenses), I don’t know how to help you.November 18, 2014 at 10:09 pm in reply to: VBScript to collect the names of douments opened in Multiple CATIA Sessions. #1389
So you launch multiple CATIA sessions on one computer?
What do you mean by “the selection of the line to start renaming your part”?
I see. The easiest way may be to have a vbOkCancel message box that tells the user that the top assembly has to be in edit mode. Then they have the option to cancel out. You could also count the number of windows before the macro, if the number of windows gets larger, exit the macro.
So you press alt+F11 to write your macros?