Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reset Properties (Change Colors to Automatics)

Status
Not open for further replies.

tpalsl125

Automotive
Apr 24, 2015
44
0
0
DE
Hi, All

I made the script to make elements reset properties.

But I have to click 'OK' button after executing the function.

Here are my youtube link and the script.

Can anybody advice about this without click 'OK' button?

Youtube

Code:
Set ActiveDoc = CATIA.ActiveDocument
Set ActDocSel = ActiveDoc.Selection

CATIA.Startcommand("Reset Properties")
 
Replies continue below

Recommended for you

I do that by working with win API you should find info if you looking for disassemble and sendkey

Eric N.
indocti discant et ament meminisse periti
 
Thank you for your reply.

I found this one to do 'disassemble' function with sendkeys.
That is very simple script, but it didn't work.
I think after executing the startcommand then the catia doesn't recognize "Disassemble" window in the 'AppActivate' method.
Could you explain to me why it doesn't work in my script?

Code:
Set oWSShell = CreateObject("WScript.Shell")
CATIA.Application.StartCommand("Disassemble")
oWSShell.AppActivate ("Disassemble")
oWSShell.SendKeys "{ENTER}"

 
I used FindWindow, ActiveWindow, sendMessage ... and google to get that done.
Also I needed tools like spy++ to understand the window interaction.

Sorry can't share code...

Eric N.
indocti discant et ament meminisse periti
 
Haha, that's cool. Foul language don't bother me, we are engineers...not babysitters. I think a lot of engineering is seen as requiring to be professional--and I do agree. But sometimes this repression of emotions seen as to befit the attitude of professional conduct, is just not a good idea.

...i wonder how Italian engineers behave [bigsmile] they're known for their emotional expression, right? lol
 
Jesus H. Christ! You gotta tell me what's up with all that? I mean...i guess macro's can be handy but at the same time to me, they're always some backwater excuse workaround for something. Are they a necessary evil?

Maybe I'm a pussy but whenever I need to do a repetitive task I just do it by hand. All logic goes out the window, just get it done. Make the boss happy, get paid, go home. It ain't much...but it's something!
 
Bang on! But I wouldn't resort to macro's, I think there needs to be a corporate-wide effort towards Knowledge-Based Engineering to truly automate repetitive and boring tasks in a way that is genuinely holistic and powerful.
 
Okay, I understand your mind.
I'll find it on the internet.
But before doing, could you tell me just one thing?!
Anyway is it possible in only using vbscript?
 
As you probably understood, is just a workaround [smile]

Code:
Language="VBSCRIPT"

Sub CATMain()

CATIA.DisplayFileAlerts = False

    Dim Message, Style, Title, Response, MyString
    Message = ("This macro will change the color of all CATParts to default CATIA color" &_
                            (chr(13)) &_
                        ""&(chr(13))&_
"   Do you want to continue ?")
    Style = vbYesNo + vbDefaultButton1    'Define buttons. Button1 means marked by default 
    Title = "Purpose "   
    Response = MsgBox(Message, Style, Title)
        If Response = vbYes Then    ' User chose Yes.
            MyString = "Yes"

Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = productDocument1.Selection

selection1.Search "CATPrtSearch.MechanicalFeature,all"

Set visPropertySet1 = selection1.VisProperties
visPropertySet1.SetRealColor 210,210,255,1

Set visProperties1 = CATIA.ActiveDocument.Selection.VisProperties
visProperties1.SetRealOpacity 255,1

selection1.Clear

selection1.Search "CATAsmSearch.Part,all"

Set visPropertySet1 = selection1.VisProperties
visPropertySet1.SetRealColor 210,210,255,1

Set visProperties1 = CATIA.ActiveDocument.Selection.VisProperties
visProperties1.SetRealOpacity 255,1

selection1.Clear

Dim specsAndGeomWindow1 As Window
Set specsAndGeomWindow1 = CATIA.ActiveWindow

Dim viewer3D1 As Viewer
Set viewer3D1 = specsAndGeomWindow1.ActiveViewer

viewer3D1.Reframe

Dim viewpoint3D1 As Viewpoint3D
Set viewpoint3D1 = viewer3D1.Viewpoint3D

End If

End Sub

Regards
Fernando

- Romania
- EU
 
Hello, Ferdo
Thanks for your reply.
I'm sorry but I've known your script. Also that is what I already found and tried.
I think this script is good solution.
But there is only one problem in your script.
That is if I directly select a face and change color then execute your script,
only that surface isn't changed.
This means actually your script change to 210,210,255,1 color, not reset color(properties).
If you watch below youtube link, you would understand what I told you.
Please, watch this link.

My Youtube
 
Is KevinDeSmet for real, or is he just joking? Are you kidding me?
Usually engineering is a very competitive field and in order to "survive" you have to be the best by working fast and with the best quality. Like Ferdo told, macro are useful for making repetitive jobs easy but also to achieve quality standards not achievable otherwise. I like at work to be relaxed and deliver my work in time and this can be done only with macro's. The are also people that take pride in their work that want to make performance, it's not only about the money at the end of the day.

For sure, it's not worth it to make macro's for tasks that you perform just a few times. Also, no company will invest in creating macro's for just a few people, that it's why in many cases it is very good to know to make macro's yourself.

 
Ferdo, Thanks for your reply.
I'm sorry, I didn't understand.
Could you explain easier for me?
And did you see my youtube link?
That is what I made in the youtube the difference your script and "reset properties".
 
Status
Not open for further replies.
Back
Top