這篇文章在網路上找到的,覺得寫得不錯可以對Pro/Program使用有深入的瞭解,
將該文章原封不動的引用過來分享。發佈者、出處如下
This article found on the Internet, I feel well written on the Pro/Program.
Share this article. Publisher, as follows
/=====================================================/
program使用
發佈者: fengsw2008 文檔分類: Java 文檔格式: DOC
出處:http://itdocument.com/679154161/
/=====================================================/
PROE/PROGRAM 其實是一門很簡單的程序設計語言。這門語言的基本詞語總共就只有 11
個:Input……End Input、Relations……End Relations、Add……End Add、Execute……End
Execute、If……End If、Massprop……End Massprop、Lookup_inst、Suppressed、Modify、Choose、
Interact。所有的一切,都是這裡11 個詞組合出來。
PROE/PROGRAM 的入口,在 2001 裡是「菜單管理器」—>」程序」.」程序」,在 WF 裡是」工
具」PART(或Assembly)
我們先看一下一般的程序都是什麼樣子:
AD1(零件的)
AD2(組件的)
兩圖上可看到, 程序可分成幾個部份, 第一部份是版本與文件信息. 第二部份是一個
Input……End Input 語句.第三部份是一個Relations……End Relations 語句.第四部份是若干個
Add……End Add 語句.第五部份是一個Massprop……End Massprop 語句.
第一部份不用管它,系統自動生成的.第二部份就是設置變量的地方.第三部份就是設置關係
式的地方.第四部份是管理所有的特徵及零件的地方.第五部份是設置質量屬性的地方.我們
用PROGRAM的重點,就在第二/三/四這三塊.
下面我先一個個說說這 11 個詞都什麼意思及如何使用.基本上兄弟們理解了它們的用法,也
就自然而然理解了程序的設計與修改了
第一個,IF……End If
這個就是各種編程語言裡都有的大名鼎鼎的條件語句了.實際上它是:
IF 條件1
……(執行語句段1)
Else
……(執行語句段2)
End If.
其含義是:如果滿足條件 1,則執行第一段的各種語句,否則,執行第二段的各種語句.Else 和第
二段是可以沒有的,但End If 是不可少的,且一個IF 對應一個End IF,其數量是相等的.IF 語句
是一個邏輯語句,使用它的目的就是實現分支設計.單獨使用是沒有意義的,它必須和其它的
語句一起使用(也就是必須有執行語句段----至少有一句).它本身可以嵌套,因此也就可以實現
多重條件的組合運用.
第二個,Input……End Input.
Input……End Input 是一個複合詞,它實際上是一個程序段,這個程序段以Input 為第一行,以
End Input 為最後一行,中間的就是我們這個程序中需要人工輸入的變量和變量類型以及相
關提示信息.程序每次再生的時候,系統會提示我們輸入這個做裡列出的每一個變量的新值.
典型的Input 段如下:
Input
A Number
B
C String
D Yes-No
EndInput
這裡有幾點要記住:
A.所有的變量都要以字母開頭.
B.變量的類型有三種:Number,String,Yes-NO.Number 就是實數型,其值是任意一個實
數,String 就是字符型,取值是任意一個字符串,Yes-No 就是布爾型,也就是取值為 YES 或 NO
之一.
C.如果設置時不指定變量類型(像上面的那個B),則系統當它是實數型.
D.當提示輸入時我們不輸入新值,則各個變量系統會取當前值,如是第一次運行時也不輸入,
則系統將實數型變量取值為0,布爾型變量取值為NO,字符串型變量取值為空.
在Input 段中可使用IF……Else……End If,以實現選擇性輸入.
在Input 段中也可為輸入變量加提示,加提示要注意:
A.提示信息必須包含在引號裡
B.提示信息必須緊跟在相應的輸入變量之後.
示例:
Input
Hole Yes-No
「請確認有無工藝孔:」
If Hole==Yes
Hole_Dia Number
「請輸入孔直徑:」
Hole_Num Number
「請輸入孔數:」
Endif
……
End Input
(以上,先確認有無孔,如果有孔,再輸入孔數與直徑,如果無孔,則不用輸入孔數與直徑)
第三個,Relations……End Relations
這個詞也是一個語句段,第一行是Relations,最後一行是End 」關係」裡編輯.如果一行關係式太
長( 最長 80 個字符一行), 可以在行尾寫一個反斜槓(\), 然後接著在下一行寫. 示例如
下:Relations,中間是零件/組件中需要用到的各種關係式.在零件/組件中加入的各種關係式
都放在這裡(不含草圖關係式及陣列關係式).在編程時也可直接在這裡增加關係,所有在這裡
的關係,都可以在」特徵」-
Relations
A=」Part0007」
B=20.0
C=d5*5/d2
D=cos(d6)
End Relations
註:眾所周知,Relations 語句段中,也可使用IF 語句.
第四個,Add……End Add
它又可細分為三種:Add Feature 特徵名……End Add,Add Part 零件名……End Add,Add
Subassembly 子組件名……End Add.它們也是語句段,第一行是Add Feature(Part/Subassembly)
特徵名(零件名/子組件名),最後一行是End Add,中間是特徵(零件/子組件)的具體信息,這些具
體信息一般來說不用去管它.因為沒有能讓我們編輯的東西.
這個語句可與IF 和Suppressed 聯用,以控制特徵(零件/子組件)的顯示與隱含.
對於特徵,這個語句段裡列出了特徵的主要參數,如尺寸/拉伸深度等,但是,要記住的是,直接在
這裡改這些參數是沒用的!!!
這裡的特徵名/零件名/子組件名,可以是字符型變量。如果是字符型變量的話,要用括號括
起來,示例:
Add Part (PartName)
第五個,Execute……End Execute
這個語句只用於組件中.它的作用是從組件向零件傳遞參數,以通過組件中的某些參數去控制
構成組件的零件(的形狀/尺寸……).它也是個語句段,第一行是 Execute,最後一行是 End
Execute,中間的每一行是一個賦值語句.典型的結構如下:
Execute
Part 變量名1=ASM變量名1
Part 變量名2=ASM變量名2
……
End Execute
通常,在組件中的Input 段和零件中的Input 段,都設置相同的變量名,代表同一個參數.(這是為
了方便,當然也可以不同,只不過不同的話就要小心點,以免搞錯).然後將零件裝配到組件中,
再編輯程序,在對應的Add Part……End Add 語句段前增加一個Execute 語句段.這樣,再生時,
給變量輸入新值,part 的形狀或尺寸就可以自動按要求變化.
第六個,Lookup_inst
這個實際上是PROE 裡的一個函數.它的取值是一個字符串,用於找出族表中符合指定條件的
特定實例的名字.具體的語法如下:
Lookup_inst(「Name」,matchmode,Valuename1,Value1,Valuename2,Value2……)
Name: 含 有 族 表 的 模 型 的 名 字 , 它 必 須 帶 後 綴 , 也 就 是 , 必 須 寫 成
如」PRT0002.prt」,」ASM0007.asm」這樣,否則,不能得出正確結果.
Matchmode:設置查找原則,取值為-1,0,1.」-1」表示查找小於等於給定值且最接近給定值的實
例,」0」表示查找等於給定值的實例,」1」表示查找大於等於給定值且最接近給定值的實例.
Valuename1/2/3...:是族表參數名,基本上也就是族表中各列的第一行那個東東.
Value1/2/3…:是用來匹配的值
示例: 零件 Part27.prt 中, 族表按尺寸 d0=50,70,90 給了三個實例, 實例名分別為
Part27-1,Part27-2,Part27-3.那麼:
Lookup_inst(「Part27.prt」,0,」d0」,50)=Part27-1
Lookup_inst(「Part27.prt」,0,」d0」,70)=Part27-2
Lookup_inst(「Part27.prt」,0,」d0」,90)=Part27-3
Lookup_inst(「Part27.prt」,-1,」d0」,60)=Part27-1
Lookup_inst(「Part27.prt」,1,」d0」,60)=Part27-2
Lookup_inst(「Part27.prt」,1,」d0」,10)=Part27-1
注意:以上的」Part27.prt」如果寫成」Part27」的話,是得不出結果的.
第七個,Suppressed
這個就是一個詞,即」壓縮」/」隱含」.它的作用跟它的詞義一樣,用於把一個特徵/零件/子組件隱
含起來,效果與在模型樹裡點右鍵用」隱含」相同.它不能單獨用,必須與Add……End Add 語句
一起使用.當想隱含哪個特徵/零件/子組件時,只要在它對應的 Add……End Add 語句的第一
行的Add 後加上Suppressed,再生之後它就不見了.
要注意的是,因為它的效果是」隱含」不是」隱藏」,所以用的時候要注意了,如果Suppressed 了父
親而不Suppressed 兒子的話,再生就要報錯的.
Suppressed 一個組或陣列中的一個子特徵,必須將所有子特徵全部 Suppressed,對於組,因組標
識在程序裡還有個單獨的Add……End Add 語句,它也要Suppressed,否則報錯.
但如果在 Config 裡加一個設置:del_gp_memb_ind=yes, 則組的各個子特徵可以單獨
Suppressed.
Suppressed 之後要恢復,可直接在模型樹裡「恢復」,也可在程序裡將Suppressed 去掉。
GOOGLE TRANSLATE
/=====================================================/
PROE / PROGRAM is actually a very simple programming language. The total number of words in this language is only 11
: Input ... End Input, Relations ... End Relations, Add ... End Add, Execute ... End
Execute, If ... End If, Massprop ...... End Massprop, Lookup_inst, Suppressed, Modify, Choose,
Interact. All in all, here are 11 combinations of words out.
PROE / PROGRAM entry, in 2001 is the "menu manager" -> "program." "Program", in the WF is the "work
PART (or Assembly)
We look at what the general procedures are like:
AD1 (of the part)
AD2 (component)
As can be seen on both figures, the program can be divided into several parts, the first part is the version and file information. The second part is a
Input ... End Input statement. The third part is a Relations ... ... End Relations statement. The fourth part is a number
Add ...... End Add statement. The fifth part is a Massprop ... End Massprop statement.
The first part of it without regard to it, the system automatically generated.The second part is to set the variable place.The third part is to set the relationship
The fourth part is to manage all the features and parts of the place.The fifth part is to set the quality attributes of the place.
With the PROGRAM focus, in the second / three / four of these three.
Now I first talk about these 11 words are what meaning and how to use. Basically, the brothers understand their usage, also
It is natural to understand the program design and modification
First, IF ... End If
This is a variety of programming languages have a well-known conditions of the statement. In fact it is:
IF Condition 1
... (Execute statement 1)
Else
... (Execute statement segment 2)
End If.
The meaning is: If the conditions 1, the implementation of the first paragraph of the various statements, otherwise, the implementation of the second paragraph of the various statements. Else and the first
Two paragraphs can not, but End If is essential, and an IF corresponding to an End IF, the number is equal.
Is a logical statement, the use of its purpose is to achieve branch design.Individual use is meaningless, it must and other
Statements (that is, there must be at least one sentence of execution statements), which itself can be nested, and thus can be implemented
Multiple conditions of the combination of use.
Second, Input ... End Input.
Input ... ... End Input is a compound word, it is actually a program segment, the program segment to Input for the first line to
End Input for the last line, the middle of this process is that we need to manually input variables and variable types and phase
Off prompt information. Each time the program is regenerated, the system prompts us to enter the new values for each of the variables listed here.
The typical Input section is as follows:
Input
A Number
B
C String
D Yes-No
EndInput
Here are a few points to remember:
A. All variables begin with a letter.
B. There are three types of variables: Number, String, Yes-NO.Number is a real type, the value is any one real
Number, String is the character type, the value is any string, Yes-No is the Boolean type, that is, the value is YES or NO
& Lt; / RTI & gt;
C. If you do not specify a variable type (such as the above B), then the system when it is real type.
D. When prompted, we do not enter the new value, the variable will take the current value of the system, the first run is not entered,
The system will be a real variable value is 0, Boolean variable value is NO, string-type variable value is empty.
You can use IF ... Else ... End If in the Input section to implement selective input.
In the Input section can also be suggested for the input variables, plus tips to note:
A. The prompt must be enclosed in quotation marks
B. The prompt message must follow immediately after the corresponding input variable.
Example:
Input
Hole Yes-No
"Please confirm whether the process hole:"
If Hole == Yes
Hole_Dia Number
"Please enter the hole diameter:"
Hole_Num Number
"Please enter the number of holes:"
Endif
...
End Input
(Above, to confirm whether the hole, if there are holes, and then enter the number of holes and diameter, if no hole, then do not enter the number of holes and diameter)
Third, Relations ...... End Relations
The word is also a statement section, the first line is Relations, the last line is End "relationship" in the edit. If a line of relationship too
Long (up to 80 characters in one line), you can write a backslash (\) at the end of the line, and then write on the next line.
The following are the relational expressions that are used in the part / component: The various relationships that are added to the part / component
(Not including the relationship between the sketch and array relational.) In programming can also be added directly to the relationship here, all here
Of the relationship, can be in the "features"
Relations
A = "Part0007"
B = 20.0
C = d5 * 5 / d2
D = cos (d6)
End Relations
Note: As we all know, the Relations statement section, you can also use the IF statement.
Fourth, Add ...... End Add
It can be subdivided into three categories: Add Feature Feature Name ... End Add, Add Part Part Name ... End Add, Add
Subassembly subcomponent name ... End Add. They are also statements, the first line is Add Feature (Part / Subassembly)
Feature name (part name / sub-component name), the last line is End Add, the middle is the characteristics (parts / sub-components) specific information, these
Body information in general do not have to ignore it because there is no let us edit things.
This statement can be used with IF and Suppressed to control the display and implication of features (parts / subcomponents).
For features, this section lists the main parameters of the feature, such as size / stretch depth, etc. However, to keep in mind, directly in the
Here to change these parameters is useless !!!
The name of the feature / part name / sub-component name, which can be a character variable. If it is a character variable, use brackets
Up, example:
Add Part (PartName)
Fifth, Execute ...... End Execute
This statement is used only in the component. Its role is to pass parameters from the component to the part to control some of the parameters in the component
It is also a statement section, the first line is Execute, the last line is the End
Execute, each line in the middle is an assignment statement. The typical structure is as follows:
Execute
Part variable name 1 = ASM variable name 1
Part variable name 2 = ASM variable name 2
...
End Execute
Normally, the same variable name, representing the same parameter, is set in the Input section of the component and the Input section in the part.
The convenience, of course, can also be different, but different words should be careful to avoid mistakes.) Then the assembly of components to components,
And then edit the program, in the corresponding Add Part ... ... End Add statement before the paragraph to add an Execute section.Thus, the regeneration,
Enter the new value for the variable, part of the shape or size can be automatically changed as required.
Sixth, Lookup_inst
This is actually a function in PROE. Its value is a string, used to find family table in the specified conditions
The specific syntax is as follows:
Lookup_inst ( "Name", matchmode, Valuename1, Value1, Valuename2, Value2 ...)
Name: The name of the model containing the family table, which must be suffixed, that is, must be written
Such as "PRT0002.prt", "ASM0007.asm" This, otherwise, can not get the correct results.
Matchmode: set the search principle, the value of -1,0,1. "- 1" that is less than or equal to the given value and the nearest given value
For example, "0" means to find an instance equal to a given value, and "1" to find an instance that is greater than or equal to the given value and closest to the given value.
Valuename1 / 2/3 ...: Family table is the parameter name, which is basically the first line in the family table that the Eastern.
Value1 / 2/3 ... is the value used to match
Example: In Part 27.prt, the family table is given three instances by dimensions d0 = 50, 70, 90, with instance names of
Part 27-1, Part 27-2, Part 27-3. Then:
Lookup_inst ( "Part27.prt", 0, "d0", 50) = Part 27-1
Lookup_inst ( "Part27.prt", 0, "d0", 70) = Part 27-2
Lookup_inst ( "Part27.prt", 0, "d0", 90) = Part27-3
Lookup_inst ( "Part27.prt", -1, "d0", 60) = Part 27-1
Lookup_inst ( "Part27.prt", 1, "d0", 60) = Part 27-2
Lookup_inst ( "Part27.prt", 1, "d0", 10) = Part27-1
Note: The above "Part27.prt" if written as "Part27", then, is not the result.
Seventh, Suppressed
This is a word, "compression" / "implied." Its role is the same as its meaning, for a feature / part / sub-component
With the right-click in the model tree with the same "implied." It can not be used alone, must be with the Add ... ... End Add statement
When you want to hide which features / parts / sub-components, as long as it corresponds to the Add ... ... End Add statement of the first
Add the line after the Add Suppressed, after regeneration it disappeared.
It should be noted that, because it is the effect of "implied" is not "hidden", so use the time to pay attention, if Suppressed the father
Pro and not Suppressed son, regeneration is the error.
Suppressed a group or a sub-feature in the array, all sub-features must be Suppressed, for groups,
In the program there is a separate Add ...... End Add statement, it should also Suppressed, otherwise an error.
However, if a setting in the Rig Riga: del_gp_memb_ind = yes, the sub-features of the group can be a separate
Suppressed.
Suppressed to restore after, can be directly in the model tree "recovery" can also be removed in the program Suppressed.
/=====================================================/