×
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!
  • Students Click Here

*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

Jobs

CATIA V5R18 Automating Point Cloud Operations with VBA

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

CODE --> VB

CATIA.StartCommand ("Import") 
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

CODE --> VB

Selection.item(x).name 
results in "CATIASelection1"

Can anyone offer insight?
Thank you in advance!

RE: CATIA V5R18 Automating Point Cloud Operations with VBA

Hi,

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

(OP)
Ok here is my attempt at an example:

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

Hi,

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

(OP)
Ferdo, Thanks for the response. I understand the idea you are expressing, and I have no issue with the string functions etc to get the name (I have more background in VB than in CATIA), but perhaps what I am missing is the proper search command you are referring to. I have tried this method:

CODE --> VB

Dim actSel As Selection
Dim i, numImported as Integer
actSel.Search "(Name=*.1)"  'imported stls are appended with ".1"
numImported = actSel.Count

For i = 1 to numImported
  MsgBox(actSel.Items(i).Name) 
Next i 

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

Search method is a little bit tricky in CATIA.

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

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!


Resources