CATIA V5R18 Automating Point Cloud Operations with VBA
CATIA V5R18 Automating Point Cloud Operations with VBA
(OP)
I have a CATPart template that consists of a number of empty geometrical sets that all begin with a smart number followed by their name. The process that I'm attempting to automate is to import .stl point clouds (already named with the same smart numbers) and then move them to their appropriate geometrical set. The workflow I have working so far is to create a new "temp" geometrical set at the end of the tree, import the .stl files. To import I used the command and let the user choose the stls to be imported. That is all well and good, but I cannot determine a way to get the names (and the smart number) of the .stl files either before or after import.
If i look at the the HybridShapes property of the temp geometrical set in the VB watch window then it shows a count of 0, yet still shows an ItemX for each stl all of which are "Empty" despite the files being fully intact. I have even found a way to select them programmatically, but grabbing the names from something like results in "CATIASelection1"
Can anyone offer insight?
Thank you in advance!
CODE --> VB
CATIA.StartCommand ("Import") If i look at the the HybridShapes property of the temp geometrical set in the VB watch window then it shows a count of 0, yet still shows an ItemX for each stl all of which are "Empty" despite the files being fully intact. I have even found a way to select them programmatically, but grabbing the names from something like
CODE --> VB
Selection.item(x).name
Can anyone offer insight?
Thank you in advance!





RE: CATIA V5R18 Automating Point Cloud Operations with VBA
Can you provide some samples? Is always easier like that to understand correct the problem.
I know that to import points there are several macros on Internet, did you tried them?
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
RE: CATIA V5R18 Automating Point Cloud Operations with VBA
The geometrical set template is along the lines of this (the numbering here doesnt really matter it is just an example):
|- 1234 Part Category A
| |- 1234_456 Part Category B
|- 789 Part Category A
|- 567 Part Category A
| |- 5678 Part Category B
So the macro is then run, which starts the digitized shape editor workbench and creates a temporary geometrical set which makes the tree like this:
|- 1234 Part Category A
| |- 1234_456 Part Category B
|- 789 Part Category A
|- 567 Part Category A
| |- 5678 Part Category B
|- TEMP IMPORT
Then the "TEMP IMPORT" geometrical set is selected and the following is run
CODE --> VB
CATIA.StartCommand ("Import")This brings up the same Catia import Window as when the import button is clicked on the digitized shape editor toolbar, which allows the user to select the .stl files they wish to import.
After importing, the tree now looks like this:
|- 1234 Part Category A
| |- 1234_456 Part Category B
|- 789 Part Category A
|- 567 Part Category A
| |- 5678 Part Category B
|- TEMP IMPORT
| |- 1234 Widget1.stl
| |- 1234_456 Widget2.stl
| |- 5678 Widget3.stl
This is where the problem sets in. I cannot find a way in VB code to get the names of the imported stl files--Importing the stls how I did does not return the names of what is imported in anyway as far as I can tell. I can see them on the screen, but the code/macro is completely unaware of the names. As I mentioned in the first post I cannot find a way to get the names from the properties of the TEMP IMPORT geometrical set. In this case Hybrid shapes property of the TEMP IMPORT geometrical set would contain Item1 through Item3 but each would be "Empty" and have no name property. Let's say I have a variable for the temp import geometrical set called "geoSet" geoSet.HybridShapes.Count would return 0 even though there are 3 items within the properties of the collection.
At this point I am unable to sort out where to move the stls as I cannot read the numbers at the beginning of the file names.
Is there something I'm missing? Am I taking the wrong approach?
Thanks in advance.
RE: CATIA V5R18 Automating Point Cloud Operations with VBA
I don't have access to digitized shape editor now and also don't have a stl file to test on another computer but if you can see stl file exactly how you described under TEMP IMPORT then you can do something like this (after importing stl files):
- search for Name = *.stl
- count all
- get the string value/name for each item and then you can split by point (or use Right command with 4 digit length) to get the stl file name
An example how to use split command is bellow (in a file with vbs extension, is working also in CATScript)
Dim strToLeft 'As String
s= "ABC123.ABCDEFGH"
strToLeft = Split(s,".")(0)
Msgbox strToLeft
Regards
Fernando
https://picasaweb.google.com/102257836106335725208
RE: CATIA V5R18 Automating Point Cloud Operations with VBA
CODE --> VB
On the msgbox line I get an error "Object doesnt support this propery or method." When I add actSel to the watch window the only properties it has are:
-Application
-Count (with correct value)
-Count2 (also with correct value)
-Name ("CATIASelection0")
-Parent
-Selection (nothing useful under here)
-VisProperties
I cannot see from this result how to extract the name. Is there another search method that does not rely on using a selection?
Thanks!
RE: CATIA V5R18 Automating Point Cloud Operations with VBA
If you will record a simple search for *.1 you will get
Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = partDocument1.Selection
selection1.Search "Name=*'.'1,all"
Usually I'm not using vba because some of our computers doesn't have vba installed and that's why I prefer CATScript (I'm aware of the huge disadvantage but...)
Regards
Fernando
https://picasaweb.google.com/102257836106335725208