×
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

Array of Parts according to selection

Array of Parts according to selection

Array of Parts according to selection

(OP)

CODE --> CATVBS

Sub CATMain()
Dim ArrayOfParts() 'As Object
Dim ArrayOfParts_size 'As Integer
Dim SelectedPart 'As Object
Dim PartFilt(0)
Set ProdDoc1 = CATIA.ActiveDocument
Set SelectedParts = ProdDoc1.Selection
PartFilt(0) = "Part"
Dim ret
ArrayOfParts_size = -1
SelectedParts.Clear
ret = SelectedParts.SelectElement2(PartFilt, "Select Part", False)
ArrayOfParts_size = ArrayOfParts_size + 1
ReDim Preserve ArrayOfParts(ArrayOfParts_size)
MsgBox TypeName(SelectedParts.Item(1).Value)
MsgBox ArrayOfParts_size
ArrayOfParts(ArrayOfParts_size) = SelectedParts.Item(1).Value
End Sub 


Hello everyone
I've got problem with filling array of parts -see code below.

Macro stops at error on line:
ArrayOfParts(ArrayOfParts_size) = SelectedParts.Item(1).Value
"Object doesn't support this property or method"

is it even possible to create array of Part object's type?

LukaszSz. Poland, Warsaw University of Technology, Faculty of Power and Aeronautical Engineering : MEchanical Engineering. BsC - 2013

RE: Array of Parts according to selection

(OP)
Solution:

CODE -->

Set ArrayOfParts(ArrayOfParts_size) = SelectedParts.Item(1).Value 

Sometimes You are not smart enough to find such dummy mistake bigglasses

LukaszSz. Poland, Warsaw University of Technology, Faculty of Power and Aeronautical Engineering : MEchanical Engineering. BsC - 2013

RE: Array of Parts according to selection

Hi luka,
I am having trouble getting my macro to Activate a node in the tree so that I can edit it. Any ideas?

RE: Array of Parts according to selection

My code:
ActiveSel.Add cattree.Products.Item(i) 'Selects My product
CATIA.StartCommand "Expand Selection"
SendKeys "1"
SendKeys "~"
doesn't work

This also doesn't work:
ActiveSel.Add cattree.Products.Item(i) 'Select VSYS_CHASSIS product
CATIA.StartCommand "Expand Selection"
hwndButtonOK = FindWindowEx(hwndExpSel, 0, "Button", "OK") 'Get handle to OK button
Foc = Putfocus(hwndExpTextbox) 'Put cursor in "Expand Selection" textbox
'SendKeys "1", True 'Choose single level expansion
lResult = SendMessage(hwndButtonOK, BM_CLICK, 0, 0) 'Press OK button

RE: Array of Parts according to selection

(OP)

CODE -->

Sub CATMain()

AppActivate "CATIA V5"

Dim cmd As String

cmd = "wscript D:\sendKeys.vbs "
Call Shell(cmd)

End Sub 

And D:\sendKeys.vbs code:

CODE -->

Set WshShell = WScript.CreateObject("WScript.Shell")

WScript.sleep 200

WshShell.SendKeys "c:Expand Selection" + "{ENTER}", True

WScript.sleep 200
WshShell.SendKeys "4", True

WScript.sleep 200
WshShell.SendKeys "{ENTER}",True 

Works well to me

Before You run macro, please select any object from tree

LukaszSz. Poland, Warsaw University of Technology, Faculty of Power and Aeronautical Engineering : MEchanical Engineering. BsC - 2013

RE: Array of Parts according to selection

Didn't work for me...

I am writing in catvba - does that help?

RE: Array of Parts according to selection

Ok...got it to work, partially (thank you) - but it only expands the tree - it does not activate the selected node as a double-click does.

Any ideas on that?

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