Before importing the CAD/BOM file defined by the user defined CAD macro, you can define the conversion script which automatically executes. If the format cannot be defined by the CAD macro editor, the following procedure will change it to be the loadable one by the user defined macro.
Define Script Defined Macro items
Item Explanation
‘Description’ Inputs description of macro if needed.
‘Script command for CAD Data’ Inputs the command to execute the CAD file conversion script
‘Use Script for BOM Data’ Selects when the BOM file is converted
‘Script command for BOM Data’ Inputs the command to execute the BOM file conversion script
‘Select User defined CAD Macro’ Selects the user defined macro used when imported after conversion.
Project050202S-01E01
Script defined CAD macro setting
When more than one error exists in the CAD/BOM file, error is displayed during loading the CAD/BOM file and import will be suspended.
To continue importing, correct the error and import.
1 Input the conversion command of the CAD file.
%INPUT% and %OUTPUT% must be
included in the command. When the command is executed, %INPUT% is replaced with the source CAD file path specified when imported, and %OUTPUT% is replaced with the
destination file path output after conversion.
Example:
Location to save the conversion script C:\Program Files\Convert\Convert.vbs Argument of script when executed Convert.vbs input file output file Conversion command to set
"C:\Program Files \Convert
\Convert.vbs" %INPUT% %OUTPUT%
2 To convert the BOM file, mark the checkbox of ‘Use script for BOM Data’
and input the conversion command of the BOM file.
3 Select the user defined macro used when imported after conversion.
4 Click [OK].
Project050202S-01E01
2 1
2 3
4
5.2 Defining CAD Macro
Example of script creation
Although the script can be registered in any language, it must meet the following conditions.
Executable from the command line
As for the command line argument, the path (including the filename) to store the input CAD file and the file after conversion should be specified
The return value when the called command is properly executed should be 0. If other than 0 is entered as the return value, export will be interrupted due to error.
Here is an example of the case that the following CAD file is loaded CAD file
PCB Board
Name TEST Length 329.50 Width 245.00
Thickness 1.20
PCB Component
no. x y angle designator component
1 58.200 42.910 90.00 C1 0001
2 73.400 35.450 -90.00 C2 0002
3 99.410 35.450 0.00 C3 0003
・
・
・
PCB length, width, thickness are in separate records so that you can load by the user defined CAD macro.
① Create the conversion script below by VB Script.
Save the script named as Test.vbs.
Set arg= WScript.Arguments
Set Fs = WScript.CreateObject("Scripting.FileSystemObject") Set regEx = New RegExp
regEx.Global = True Dim BoardSize(2)
Set InputFile = Fs.OpenTextFile(arg(0),1) Set OutputFile = Fs.CreateTextFile(arg(1),True) InputAllStr = InputFile.ReadAll
GetBoardSize InputAllStr
OutputFile.WriteLine "BOARD_SIZE " & BoardSize(0) & " " & BoardSize(1) & " " &
BoardSize(2) OutputFile.WriteLine OutputFile.Write InputAllStr InputFile.Close
OutputFile.Close Sub GetBoardSize(str)
regEx.Pattern = "(Length|Width|Thickness)\s*(\d+\.*\d*)"
Set Matches = regEx.Execute(str) For i = 0 To Matches.Count-1
If StrComp(Matches(i).SubMatches(0),"Length") = 0 Then BoardSize(0) = Matches(i).SubMatches(1)
ElseIf StrComp(Matches(i).SubMatches(0),"Width") = 0 Then BoardSize(1) = Matches(i).SubMatches(1)
ElseIf StrComp(Matches(i).SubMatches(0),"Thickness") = 0 Then BoardSize(2) = Matches(i).SubMatches(1)
End If Next End Sub
② Specify the sample CAD file to the first argument and the output destination file to the second argument, and execute the script, the output file shall be as follows.
BOARD_SIZE 329.50 245.00 1.20 PCBComponent
no. x y angle designator component
1 58.200 42.910 90.00 C1 0001
2 73.400 35.450 -90.00 C2 0002
3 99.410 35.450 0.00 C3 0003
・
・
・
Create the file system object Create the formal expression object
Saves the PCB size L, W and T
Open the file in read only mode Create the output file Load all lines in the file
Save the PCB size in the BoardSize
Output the PCB size lineto the output file
Write the original CAD data to the output file
Close the file
Function to get the PCB size
Formal expression matched to the line of the PCB size
Output PCB length, width, thickness are in a line so that you can load by the user defined CAD macro.
Create argument object
5.2 Defining CAD Macro
③ When script is stored in C:\, the script defined CAD macro is defined as follows.
‘C:\TEST.vbs %INPUT% %OUTPUT%’
Choose the user defined CAD macro for loading the file after conversion.
Project050202S-02E01
About standard CAD macro
The standard CAD macro is initially registered in the CAD macro list. It is defined to load all parameters which can be defined by the CAD macro function. By creating the output script by the specified format and creating the script definition CAD macro, you can load the CAD file without creating the user definition CAD macro.
The standard CAD macro loads a CSV file format (comma-delimited format) so that please follow the format below. The sample file is saved in the following folder.
(Install drive)\Program Files\Panasonic-MES\Client\Samples\StandardCAD.txt Example of the standard CAD format
//Offset
//field,X,Y,Angle,Designator,Side,Rivision,Product,Version,Comments,PatternDesignator Offset,0,0,0,Offset1,T,1,1,1,Comments,P1
Offset,100,100,180,Offset2,T,1,1,1,"Comments 1",P1 Field must delimit with “,”(commas).
If space is included in the letter springs, it must enclose in " " (double quotation marks).
Write one data (Example: 1 placement point) in one line.
The head field represents the record type.
(The above record is offset)
Example: Type “Placement” at the head field in the placement point record.
Set the required values for each record type after the field.
Items to set by the fields are the same as those defined by the user definition macro.
The line that the head field is not specified record type letters is skipped as comment.
5.2 Defining CAD Macro
Standard CAD macro record type
Record type Letters shown Field number Description
Offset Offset 1 Letters shown as record type
2 X-coordinate 3 Y-coordinate 4 Rotation
5 Reference number
6 Mount side
7 Revision code
8 Version number
9 PCB name
10 Comment
11 Pattern identifier
Master bad mark MasterBadMark 1 Letters shown as record type 2 X-coordinate 3 Y-coordinate
4 Mount side
5 Mark name
6 Comment Pattern bad mark
(all patterns) PatternBadMark 1 Letters shown as record type 2 X-coordinate 3 Y-coordinate
4 Mount side
5 Mark name
6 Comment
7 Pattern identifier
Pattern mad mark
(option specify) OptionalBadMark 1 Letters shown as record type 2 X-coordinate 3 Y-coordinate
4 Mount side
5 Mark name
6 Offset reference number
7 Comment
8 Pattern identifier
Pattern mark PatternFiducial 1 Letters shown as record type
2 X-coordinate 3 Y-coordinate 4 Letters shown as record type
5 Mark name
6 Comment
7 Pattern identifier
Record type Letters shown Field number Description
PCB mark PanelFiducialMark 1 Letters shown as record type
2 X-coordinate 3 Y-coordinate
4 Mount side
5 Mark name
6 Explanation
Placement point Placement 1 Letters shown as record type
2 X-coordinate 3 Y-coordinate 4 Rotation
5 Part name
6 Reference number
7 Mount side
8 Explanation
9 Pattern identifier
10 Part description
Non placement point
(Unused) DiscardedPlacement 1 Letters shown as record type
2 X-coordinate 3 Y-coordinate 4 Rotation
5 Part name
6 Reference number
7 Mount side
8 Explanation
9 Dispense angle
10 Insertion pitch
11 Placement order
Placement point
recognition CompornentFiducial 1 Letters shown as record type 2 X-coordinate 3 Y-coordinate
4 Mount side
5 Mark name
6 Reference number
7 Explanation
8 Pattern identifier
PCB outline PanelOutline 1 Letters shown as record type
2 X-coordinate 3 Y-coordinate
4 X-coordinate 2
5 Y-coordinate 2
6 PCB thickness
5.2 Defining CAD Macro
Record type Letters shown Field number Description
Pad Pad 1 Letters shown as record type
2 X-coordinate 3 Y-coordinate
4 X direction size
5 Y direction size
6 Mount side
7 Reference number
8 Layer
9 Net ID
10 Shape
11 Recognition necessary
12 Rotation
Hole Hole 1 Letters shown as record type
2 X-coordinate 3 Y-coordinate
4 X direction size
5 Y direction size
6 Mount side
7 Reference number
8 Shape
Trace segment TraceSegment 1 Letters shown as record type
2 X-coordinate 3 Y-coordinate
4 X-coordinate 2
5 Y-coordinate 2
6 PCB thickness
7 Layer
8 Net ID
9 Thickness PCB warpage detection
position WarpMeasurement 1 Letters shown as record type
2 X-coordinate 3 Y-coordinate
4 Mount side
For interpretation of each record and field, see
( ‘5.2.1 CAD Macro Editor ■Relationship of record types and field definition’ )