Register
 
DoubleCAD XT v5 has released

(PRO only): Creating Parametric Parts and using scripts.
Read 10853 times
March 27, 2009, 05:12:33 PM
One important DoubleCAD XT Pro feature is the PPM, or Parametric Parts Manager. 

While looking for a couple easy scripts I wrote, I found two others from Brian that are probably less complex operations. 

I'm not giving them to you in .ppm form (intentionally  ;)).  You can find documentation on the PPM beginning on page 307 of the DoubleCAD XT Pro manual.

With the scripts below, you will need to open the Parametric Part Script Manager palette, click on the New icon, then cut and paste the script into the palette.  Click to save it somewhere.  Then press the play button (with the right arrow).  That will place an instance of the part in the drawing.  Select that part and go to Selection Info to change the parametric aspects...

Script 1 (just the black text):

Wide=Parameter("Wide", 1, Interval(1,10));
Long=Parameter("Long", 4, Interval(1,10));
High=Parameter("High", 9, Interval(1,10));
Dist=Parameter("Distance", 12, LINEAR);

///Draw Geometry
Hole1=Rectangle(8,8);
Base1=Rectangle(10,10);

Block1=Thickness(Base1,10);

Hole2=Thickness(Hole1,12);
Hole3=Move(Hole2,0,0,-1);
Hole4=RotateY(Hole3, 90);
Hole5=Move(Hole4,-5,0,5);
Hole6=RotateZ(Hole4, 90);
Hole7=Move(Hole6,0,-5,5);

Block3=BooleanSubtract(Block1,Hole3);
Block4=BooleanSubtract(Block3,Hole5);
Block5=BooleanSubtract(Block4,Hole7);
Block6=SetProperties(Block5,"PenColor"= 0xFF0000);


//arrange blocks
Final1 = Move(Block6,Dist,0,0,Wide);// Make the number of copie3w = wide
Final2 = Move(Final1,0,Dist,0,Long);// Make the number of copie3w = long
Final3 = Move(Final2,0,0,Dist,High);// Make the number of copie3w = high

Output(Final3);




XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
And Script 2:


Units(1[in]);

Wid=Parameter("Picket Width", 2, LINEAR, Set(2, 2.5, 3, 4, 6));
Dep=Parameter("Picket Thickness", 1, LINEAR, Set(1, 2, 3));
PickHeight=Parameter("Picket Height", 48, LINEAR, Set(36,48,60,72));
Pointy=Parameter("Depth of Picket Point", 4, LINEAR, Set(2,4,6,8,10));
Len=Parameter("Length of Fence", 72, LINEAR, GreaterThan(72));
Num=Parameter("Number of Pickets", 12, LINEAR, GreaterThan(6));
RailWid=Parameter("Width of Rails", 4, LINEAR, Set(2, 2.5, 3, 4, 6));
RailDepth=Parameter("Depth of Rails", 2, LINEAR, Set(2, 2.5, 3, 4, 6));
BotRail=Parameter("Height of Bottom Rail", 12, LINEAR, Set(0, 6, 12, 18));
TopRail=Parameter("Height of Top Rail", 36, LINEAR, Set(24, 36, 48, 60));
PostSize=Parameter("Size of Post", 4, LINEAR, Set(2,4,6));


Div=Len/(Num-1);
Space=(Div-(Wid/(Num-1)));


// Pickets
PicketProfile=Polyline(
Point(0,0),
Point(0,-Wid),
Point((PickHeight-Pointy),-Wid),
Point(PickHeight,-Wid/2),
Point((PickHeight-Pointy),0),
Point(0,0)
);

Picket1=Thickness(PicketProfile,Dep);
Picket2=RotateX(Picket1,-90);
Picket3=RotateY(Picket2,-90);
Picket4=Move(Picket3,0, 0, 0);
Picket5=RotateZ(Picket4, 180);
Picket6=Move(Picket5, Space, 0, 0,(Num));
Picket7=Move(Picket6,-Space, 0, 0);


Output (Picket7);

//Rails
Rail1=Rectangle(RailWid,RailDepth);
Rail2=RotateY(Rail1,90);
Rail3=Thickness(Rail2, Len);
Rail4=Move(Rail3, 0, RailDepth/2, BotRail);
Rail5=Move(Rail4, 0, 0, TopRail-BotRail);

Output(Rail4,Rail5);


Post=Rectangle(PostSize,PostSize);
Post2=Thickness(Post,TopRail+RailWid/2);
Post3=Move(Post2, -PostSize/2, PostSize/2,0);

Output(Post3);


XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
That's all there is to it.  Try looking at them in an ISO view...

-- William
« Last Edit: May 15, 2009, 02:26:26 PM by wmanning »

Logged
DoubleCAD XT Pro on XP Pro...


March 27, 2009, 05:17:47 PM
#1
It isn't easy to write a .ppm file from a script if it isn't documented.  That documenation didn't make it into the final DoubleCAD XT Pro manual, so I am adding a strong draft of it here.  The attached document is taken from the TurboCAD Pro v16 documentation and was converted for DoubleCAD.  Any problems with formatting are my fault.

Parts created as .ppm files can be used in both applications.  There are one or two commands that may be TurboCAD only functions, and I'm looking into that.  They apply the chamfers or fillets to 3D objects.

And if you are wondering what a .ppm part even looks like in action, there is a new video with a couple of basics in 2D alone... coming Monday.  Until then, try it!

I'd love to see some people give this function a try... I know it is not for everyone!

- william

Logged
DoubleCAD XT Pro on XP Pro...


* March 27, 2009, 06:54:27 PM
#2
How might parametric parts be usefull to the architectural industry?
Seasdes

Logged


* March 27, 2009, 08:09:36 PM
#3
Thank you. I've been meaning to read up on this - ever since you told me that it was like sketchup's dynamic components - but more powerful (and less easy  ;D )

I'd like to second Seasdes's query/request: could you give an architectural example, please - like, say, railings where the no. of balusters increase depending on length. (Would that be a valid example?)

Thanks.

Logged


March 29, 2009, 07:54:02 AM
#4
We'll get back to you on the architectural items because my head is more in the weekend mode than list making mode ;) but a few examples...

Try the second script above for a dynamic picket fence.  You could make that into a balustrade. You railings with balusters increasing in numbers is valid.  You could also use parametrics to vary the design of the balusters.  You could also create dynamic furniture so that you have a couch with 6' length or 8' length.  Chairs with or without arms, bookshelves with different widths or number of shelves... the list is endless.

What I wouldn't do is try to use parametric parts as a replacement or work-around for the architectural tools themselves: the doors, windows, walls, stairs, railings, slabs, and roofs that are AEC parametric objects compatible with AutoCAD Architecture objects.

Another area could be to use parametric parts to create 2D symbols.  Image in landscape architecture if you had plants with different appearance for different seasons, or for different growth sizes at 1 year, 5 years, and 15 years size.  They could be changed even after they are in model by changing their Selection Info.

We'll put together more, and hopefully better examples for you tomorrow.

-- William

Logged
DoubleCAD XT Pro on XP Pro...


* March 30, 2009, 04:27:53 AM
#5
Thanks, but I'm having problems inserting the part. I opened the ppm folder, after much searching (it was in the "symbols" folder) and opened the "parametric door". So far so good; but, when I clicked on "insert", nothing happened.  ??? Could it be that the symbols wasn't in the "regular" path? -- in which case the blocks/symbols shouldn't show up, either (They do!)

FWIW, my first impression is that it would be lovely if it could be simplified a bit, and made more visual. It's, just perhaps, a bit more complicated than it should be for a program that could be a more intuitive replacement to Autocad. But, who knows, with a little more study, I should be able to learn enough to modify scripts to do my job - as in Autocad.On the whole,  a definite plus.

ps: Haven't tried out the "pickets" scripts yet. Will do so tonight.
pps: You really shouldn't have disturbed your weekend to reply to this; I could've waited: I' sure there are a lot more important things to do (like a wife or/and kids). Thanks, anyway.

Logged


* March 30, 2009, 05:39:40 AM
#6
Wow! Does it work! Well, actually the door.ppm also did work -- but both were so tiny (compared to the rest of the drawing I was "working" on) that I didn't notice them But your suggestion about seeing it in isometric view did the trick.

How might parametric parts be usefull to the architectural industry?
Seasdes
A  graphic example (from his second script). Incidentally - this is a small point - the "Number of pickets" is shown at "1'-0" "  ;).

I wonder if the script could be modified to take an irregular polyline and arrange the pickets along them.







« Last Edit: March 30, 2009, 05:41:19 AM by makr »

Logged


March 30, 2009, 06:58:10 AM
#7
It is how the # of picketts is defined in the script - it is possible for it to be adjusted so that it shows just an integer value.

regarding the Polyline - The PPM is not set for "selection" of external objects, But it could be written to define the polygon - althought that would be more complicated to write.

Logged


* March 30, 2009, 07:12:06 AM
#8
Thanks. Would it have something like autolisp's "pause" function, which could allow you to pick points on the screen - or, rather, draw them. We could then draw the pline, an have the picket/baluster follow it. (Even if it doesn't, it does seem to have a lot of power per se. I've a feeling that, a bit simplified it could be enormously popular - like the ruby scripts in Sketchup. Or, perhaps even if it isn't simplified.)

Logged


March 30, 2009, 10:39:51 AM
#9
It doesn't have something like that pause function at the moment, but it is still a feature that we know could be improved in future versions, so suggestions are welcome.

Logged
DoubleCAD XT Pro on XP Pro...


May 17, 2009, 07:57:32 PM
#10
It isn't easy to write a .ppm file from a script if it isn't documented.  That documenation didn't make it into the final DoubleCAD XT Pro manual, so I am adding a strong draft of it here.  The attached document is taken from the TurboCAD Pro v16 documentation and was converted for DoubleCAD.  Any problems with formatting are my fault.

Parts created as .ppm files can be used in both applications.  There are one or two commands that may be TurboCAD only functions, and I'm looking into that.  They apply the chamfers or fillets to 3D objects.
Is this .doc different than the .pdf in the beta group?

Logged
Cheers
~Nick

Home-Dell T3400 Quad Core Q6600 OC'd 3 GHz., 8 GB RAM, Radeon HD 3870, Windows 7 x64
ACAD 2012, DoubleCAD XT Pro v3, Alibre 2012 Expert, 123D


May 21, 2009, 02:03:29 PM
#11
In Regard to:


Quote
Parts created as .ppm files can be used in both applications.  There are one or two commands that may be TurboCAD only functions, and I'm looking into that.  They apply the chamfers or fillets to 3D objects.

Actually, one of the fixes in the M-1 prevents PPM objects from being available in the XT product - They were causing crtashes in XT - This will be rectified by v2.


Logged