logo
NOTICE:  This is the new PunchCAD forum. You should have received an email with your new password around August 27, 2014. If you did not, or would like it reset, simply use the Lost Password feature, and enter Answer as the security answer.
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
murrayagain  
#1 Posted : Friday, October 13, 2023 6:16:13 PM(UTC)
murrayagain

Rank: Guest

Joined: 2/13/2023(UTC)
Posts: 24

Was thanked: 16 time(s) in 8 post(s)
I've not been able to use macro to achieve anything at all. The brief note about macro in the user guide says it's an import format that opens and processes a text file, and gives a list of the acceptable instructions. Tim, Todd, anyone with the skinny, please give us some repeatable instruction that demonstrates how it works!
thanks 2 users thanked murrayagain for this useful post.
creativecad on 10/13/2023(UTC), damhave on 10/14/2023(UTC)
damhave  
#2 Posted : Saturday, October 14, 2023 1:14:27 AM(UTC)
damhave

Rank: Guest

Joined: 9/14/2020(UTC)
Posts: 70
Man
Denmark

Thanks: 186 times
Was thanked: 43 time(s) in 26 post(s)
Hi,
There are some very good examples here:
http://forum.punchcad.co...sts&t=5679#post18087
Moreover an export macro has been added to V14, but it only supports circles, arcs, lines, splines and text. Unfortunately is "Point" not supported (Feature Request!).

Everything below is just my observations and should be considered as a guess (no/obsolete documentation):

the macros can be used in two ways.
1) 2D drawings (see the syntax below)
2) Making 3D objects from 2D drawings with Extrude and Revolve (probably also Sweep) and boolean operations. It seems the Extrude and Revolve (and maybe Sweep) creates an objectID that can then be used for Move and Rotate operations Unfortunately is there no Copy/Clone (Feature Request!) command. When using boolean operations the first listed objectID is keept as and objectID for the combined object.

I cannot get the #Sphere, #Cone, #Box, #Cylinder commands to work. I can make a sphere with a diameter of eg. 10mm but I can not get the position to work. Moreover I assume the created 3D object get an objectID so it can be referenced by other commands but it did not seem to work this way or I did it wrong...

When you export drawing as a macro it writes the macro syntax in the beginning of the file. See below. It is very important that "Keep_Constructions, True" is in the file otherwise the lines will not show up and be deleted because they are assumed to be construction lines" for Extrude and commands.

The syntax for macro import seems to be the simple macro language described in the SharkCAD user manual plus the new commands listed below although not all spline types that can be exported seems to be imported (not implemented/sw bug?).

units in the macrofile seems to be inches

Try starting wit a drawing with a simple line and use the export macro function, see example below.

Note the comma between the command and the first parameter. If omitted the command will not work.

kind regards
Danny

A macro file export of a single line.
:
//Geometry Formats Supported for Macro
// Circle, centerX, centerY, centerZ, radius
// Arc, centerX, centerY, centerZ, radius, startAngle, endAngle
// Line, p1.x, p1.y, p1.z, p2.x, p2.y, p2.z
// Interopolate Spline, point number, pt.x, pt.y, pt.z
// Bezier Spline, point number, pt.x, pt.y, pt.z
// Control Point Spline, point number, pt.x, pt.y, pt.z
// Interopolate Spline, point number, pt.x, pt.y, pt.z
// Text, pt.x, pt.y, pt.z, text string:
//
Keep_Constructions, True
#Line, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0

Edited by user Sunday, October 15, 2023 2:56:24 AM(UTC)  | Reason: added missing word and missing copy/clone, added comment about comma, added not all spline types

BR
Danny

Windows 10 Pro,
SharkCAD v14 Pro (1653),
XPS 15,9980HK
Sonoma 14.3,
SharkCAD v14 Pro (1653),
MacBook Pro 14 2023,M3
thanks 1 user thanked damhave for this useful post.
MPSchmied on 10/14/2023(UTC)
murrayagain  
#3 Posted : Saturday, October 14, 2023 6:04:16 AM(UTC)
murrayagain

Rank: Guest

Joined: 2/13/2023(UTC)
Posts: 24

Was thanked: 16 time(s) in 8 post(s)
Danny, thank you very much! This is fantastic, it ought to be part of the installation package. Thanks to Roland too. I should've read it way back then, but on the other hand, it's only been in recent years that I've started learning how to use scripting, and to realise how much it can extend existing capability without having to wish (or wait) for new tools..
damhave  
#4 Posted : Saturday, October 14, 2023 7:28:42 AM(UTC)
damhave

Rank: Guest

Joined: 9/14/2020(UTC)
Posts: 70
Man
Denmark

Thanks: 186 times
Was thanked: 43 time(s) in 26 post(s)
Thanks :-)
I got the import macro import with Spheres to work. The command name was wrong in the manual. the command name is "Sphere" not "#Sphere" as stated in the manual.
Below (I cannot attach a macro file to the post) is a small macro script to paste into a .macro file for import.
kind regards
Danny

//Import Sphere Macro Test
// 3 spheres are created at 0,0,0 and with the "Sphere" commands and they are moved into place with the 3 "Move" commands
//
// Syntax for the Sphere command is: Sphere, ObjectID, Radius
// Where ObjectID shall be a number (a name with characters seems to work but only for the first object probably because it evaluates to zero)
// and radius (OBS radius - not diameter) is in inches.
// OBS: the command name is "Sphere" not "#Sphere" as described in the Sharkcad V14 user manual
//
// Syntax for the Move command is a: Move, ObjectID, x1, y1, z1, x2, y2, z2
// Where ObjectID is the 3D object that is moved and the coordinates is a vector that will typically start in the origin (x1,y1,z1=0,0,0) and x2,y2,z2 is the destination for the move. coordinate units in inches.
//
Sphere,1000,2
Move,1000,0,0,0,0,0,10
Sphere,2000,3
Move,2000,0,0,0,0,0,20
Sphere,3000,4
Move,3000,0,0,0,0,0,30

Edited by user Saturday, October 14, 2023 8:20:10 AM(UTC)  | Reason: grammar

BR
Danny

Windows 10 Pro,
SharkCAD v14 Pro (1653),
XPS 15,9980HK
Sonoma 14.3,
SharkCAD v14 Pro (1653),
MacBook Pro 14 2023,M3
thanks 1 user thanked damhave for this useful post.
MPSchmied on 10/14/2023(UTC)
damhave  
#5 Posted : Saturday, October 14, 2023 8:59:09 AM(UTC)
damhave

Rank: Guest

Joined: 9/14/2020(UTC)
Posts: 70
Man
Denmark

Thanks: 186 times
Was thanked: 43 time(s) in 26 post(s)
Got the import macro import with Boxes to work. The command name was also wrong in the manual. See the example below


// Import Box Macro Test
// 2 boxes are created at 0,0,0 with the "Box" commands and they are moved into place with the 2 "Move" commands
//
// Syntax for the Box command is: Box, ObjectID, XSize, YSize, ZSize
// Where ObjectID shall be a number and x,y,z size dimensions are in inches.
// OBS: the command name is "Box" not "#Box" as described in the Sharkcad V14 user manual
//
// Syntax for the Move command is a: Move, ObjectID, x1, y1, z1, x2, y2, z2
// Where ObjectID is the 3D object that is moved and the coordinates is a vector that will typically start in the origin (x1,y1,z1=0,0,0) and x2,y2,z2 is the destination for the move. coordinate units in inches.
//
Box,1000,1,2,3
Move,1000,0,0,0,0,0,10
Box,2000,4,5,6
Move,2000,0,0,0,0,0,20
BR
Danny

Windows 10 Pro,
SharkCAD v14 Pro (1653),
XPS 15,9980HK
Sonoma 14.3,
SharkCAD v14 Pro (1653),
MacBook Pro 14 2023,M3
thanks 1 user thanked damhave for this useful post.
MPSchmied on 10/14/2023(UTC)
damhave  
#6 Posted : Saturday, October 14, 2023 9:11:53 AM(UTC)
damhave

Rank: Guest

Joined: 9/14/2020(UTC)
Posts: 70
Man
Denmark

Thanks: 186 times
Was thanked: 43 time(s) in 26 post(s)
And an example of the syntax for the Cylinder command:

//Import Cylinder Macro Test
// 2 Cylinders are created at 0,0,0 with the "Cylinder" commands and they are moved into place with the 2 "Move" commands
//
// Syntax for the Cylinder command is: Cylinder, ObjectID, Radius, ZSize
// Where ObjectID shall be a number and Radius and ZSize (height) are in inches.
// OBS: the command name is "Cylinder" not "#Cylinder" as described in the Sharkcad V14 user manual
//
// Syntax for the Move command is a: Move, ObjectID, x1, y1, z1, x2, y2, z2
// Where ObjectID is the 3D object that is moved and the coordinates is a vector that will typically start in the origin (x1,y1,z1=0,0,0) and x2,y2,z2 is the destination for the move. coordinate units in inches.
//
Cylinder,1000,1,4
Move,1000,0,0,0,0,0,10
Cylinder,2000,2,8
Move,2000,0,0,0,0,0,20

Edited by user Saturday, October 14, 2023 9:12:30 AM(UTC)  | Reason: copy paste error

BR
Danny

Windows 10 Pro,
SharkCAD v14 Pro (1653),
XPS 15,9980HK
Sonoma 14.3,
SharkCAD v14 Pro (1653),
MacBook Pro 14 2023,M3
thanks 1 user thanked damhave for this useful post.
MPSchmied on 10/14/2023(UTC)
damhave  
#7 Posted : Saturday, October 14, 2023 9:58:54 AM(UTC)
damhave

Rank: Guest

Joined: 9/14/2020(UTC)
Posts: 70
Man
Denmark

Thanks: 186 times
Was thanked: 43 time(s) in 26 post(s)
And an example of the syntax for the Cone command (Truncated Cone command).
(Evt. use Edit:Change Resolution:Precise Facets on the large cone to make it look nicer after running the macro)

//Import Cones Macro Test
// 2 Cones (in fact frustum of Cone) are created at 0,0,0 with the "Cone" commands and they are moved into place with the 2 "Move" commands
// The Cone command seems to be a Truncated Cone command - it is not possible to omit the top radius or use 0 for the upper radius.
//
// Syntax for the Cone command is: Cone, ObjectID, BottomRadius, TopRadius, ZSize
// Where ObjectID shall be a number and BottomRadius, TopRadius and ZSize (height) are in inches.
// OBS: the command name is "Cone" not "#Cone" as described in the Sharkcad V14 user manual
//
// Syntax for the Move command is a: Move, ObjectID, x1, y1, z1, x2, y2, z2
// Where ObjectID is the 3D object that is moved and the coordinates is a vector that will typically start in the origin (x1,y1,z1=0,0,0) and x2,y2,z2 is the destination for the move. coordinate units in inches.
//
Cone,1000,2,1,4
Move,1000,0,0,0,0,0,10
Cone,2000,4,0.00001,8
Move,2000,0,0,0,0,0,20

Edited by user Saturday, October 14, 2023 10:36:46 AM(UTC)  | Reason: Not specified

BR
Danny

Windows 10 Pro,
SharkCAD v14 Pro (1653),
XPS 15,9980HK
Sonoma 14.3,
SharkCAD v14 Pro (1653),
MacBook Pro 14 2023,M3
thanks 1 user thanked damhave for this useful post.
MPSchmied on 10/14/2023(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.