The first step in adding DWG output to your Project is to Mixin the DwgDrawingMixin Design at the root node of your drawing. This Mixin has Rules that look down the tree into the Children and gather data for the DWG file.
DwgDrawingMixin has a Rule, DWGOutputParts, that is a list of all the kBridge parts to output to the DWG file. This Rule is a Parameter that defaults to a collection of all the possible output parts from this node in the tree on down. However, you can pass in your own array of kBridge parts to be output in the file.
There are only certain Designs that can currently be translated into DWG objects. When you want a Design to be present in the outputs, there are 2 options:
•include Mixin Designs
•add specific Rules to the kBridge Design
Design |
Purpose |
Key Rules |
DWGComponentMixin |
This is a Mixin to every Design that requires a DWG output |
Layer |
DWGBoxMixin |
Mixin for any block based Designs |
DWGDataNode |
DWGCylinderMixin |
Mixin for any cylinder based Designs |
DWGDataNode |
DWGLineMixin |
Mixin for a line |
DWGDataNode |
DWGPolygonMixin |
Mixin for a polygon Design. Not yet implemented |
DWGDataNode |
DWGDrawingMixin |
This is the main Mixin for generating a dwg. |
OutputFile - defines the name of the output file. The generated dwg actually gets put in a special temp directory somewhere on the server. DWGOutputParts - This is the list of objects to output. Currently, it collect all the leaves from this part on down that have a DWGDataNode Rule |
DWGBlockReference |
This is used for adding an AutoCAD block to the drawing. The block can either be from an external file, or within the template file |
DWGDataNode InsertionPoint Scale BlockAttributes - This is an array of name and value pairs that get passed down to the block. RotationAngle - defaults to 0 BlockName-Name of the block in the template file to use in the drawing. If the BlockDWGFileName input is not empty, it will use that instead BlockDWGFilename-Path and name of the dwg file containing the block. If this is not empty, the program will ignore the BlockName input
|
The second method for getting Designs included in the DWG file is to add 2 Rules to the Design.
●Layer - This is a string that corresponds to the dwg layer of the object
●DWGDataNode - This is a javascript object that describes the geometry and properties of the part to output. Currently the translator is only able to handle a small set of AutoCAD objects. The following text shows the data needed for each type of object.
NOTE: in the tables below, "Plist" indicates the entities found in the AutoCAD property list, a configuration file within the AutoCAD envrionment.
DWG Properties Object
Plist item name |
Description |
Value |
Layer |
Layer name of this element |
this.layer |
Linetype |
Line type of the object |
"byblock" |
Linetypescale |
Used to control the spacing on dashed lines |
3 |
Lineweight |
Line thickness |
-3 |
Plist item name |
Description |
Value |
Name |
"Box" |
|
Height |
Box height |
this.height |
Width |
Box width |
this.width |
Length |
Box length |
this.length |
Properties |
Properties object |
See "DWG Properties Object" above |
Transform |
Transformation matrix for this particular block |
this.transform._matrix.elements |
DWGCylinderMixin DWGDataNode
Plist item name |
Description |
Value |
Name |
"Cylinder" |
|
Height |
Height of the cylinder |
this.height |
RadiusX |
this.radius |
|
RadiusY |
this.radius |
|
TopRadius |
this.topRadius |
|
Properties |
Properties object |
See "DWG Properties Object" above |
Transform |
Transformation matrix for this particular block |
this.transform._matrix.elements |
Plist item name |
Description |
Value |
Name |
"Line" |
|
StartPoint |
Start point for the line in jsonformat {"X": x, "Y": y, "Z": z} |
{"X": this.p0.x, "Y": this.p0.y, "Z": this.p0.z} |
EndPoint |
Start point for the line in json format {"X": x, "Y": y, "Z": z} |
{"X": this.p1.x, "Y": this.p1.y, "Z": this.p1.z} |
Properties |
Properties object |
See "DWG Properties Object" above |
Transform |
Transformation matrix for this line |
this.transform._matrix.elements |
Plist item name |
Description |
Value |
Name |
"Mtext" |
|
TextHeight |
Height of the text characters |
|
Location |
X,Y,Z of text center |
{"X": this.origin.x, "Y": this.origin.y, "Z": this.origin.z} |
Contents |
Text that can include unicode escape characters like \u0000D (line feed) |
this.text |
Properties |
Properties object |
See "DWG Properties Object" above |
Transform |
Transformation matrix for this particular block |
this.transform._matrix.elements |
Plist item name |
Description |
Value |
Name |
"Viewport" |
|
Height |
Height of the viewport |
this.height |
Width |
Width of the viewport |
this.width |
CenterPoint |
X,Y,Z of the viewport center on the paper space. Z = 0 |
|
Transform |
Transformation matrix for this viewport |
this.transform._matrix.elements |
ZoomFactor |
Inverse of the scale of the viewport |
1/this.scale |
ViewCenter |
Center of the view in this viewport |
this.view.viewpoint |
ViewDirection |
Eyepoint of the view in the eyepoint |
this.view.eyepoint |
Upvector |
The vector in 3d space that maps to the top vector of the viewport in layout space |
this.view.upvector |
Renderstyle |
The display style for the geometry in the viewport. Possible values: "shaded","wireframe","hidden" |
this.DWGRenderStyle |
VisibleLayers |
This is an array of the layer names of the parts visible in this viewport |
this.DWGVisibleLayers |
Plist item name |
Description |
Value |
Name |
"BlockReference" |
|
Blockname |
Name of the block to use from the template file. If using a dwg file for this block, this is an empty string |
this.BlockName |
DrawingFileName |
Path to the block dwg file |
this.BlockDWGFileName |
InsertionPoint |
X,Y,Z of block center |
this.origin |
Scale |
Scale factor to apply to the block |
{X: this.scale,Y: this.scale, Z: this.scale} |
Angle |
Angle of rotation |
this.RotationAngle |
Transform |
Transformation matrix for this particular block |
this.transform._matrix.elements |