#DesignScript LM – Chapter 24 -Part III: Intersection, Trim, and Select Trim

Hi Everyone:

Getting right to it, this is the third part of chapter 24, from the DesignScript Language Manual and can be found at DSLM  (page-73) and is entitled;  Intersection, Trim, and Select Trim. There is a companion video tutorial on Trim & Intersection(#17) which can be found on the DS website’s tutorials.

The initial manual translation was made on the Autodesk DesignScript Community Forum and DesignScript.org. Now it can be found at can be found at  Chapter 24: Intersection, Trim, and Select Trim, Part #3(Note that it can be not longer be found on the Autodesk Labs Website, as linked)

Copy and paste the script from (page 73) the Design Script Language Manual into the DesignScript Editor.  Below shows the script in the  DS  Editor with the results of the code being run, and the window graphics inserted alongside for reference.

Chp-24_intersection_trim_selectTrim-add_perimeter-ds#3

Chp-24_intersection_trim_selectTrim-add_perimeter-ds#3

Now open DesignScript Studio and paste this same script into the canvas.

Chp-24_intersection_trim_selectTrim-add_perimeter#a3

Chp-24_intersection_trim_selectTrim-add_perimeter#a3

Note script is inactive as it has been commented out.

Chp-24_intersection_trim_selectTrim-add_perimeter#a3-edited

Chp-24_intersection_trim_selectTrim-add_perimeter#a3-edited

After editing the “commenting out” the script is then run. Its seen that due to the fact that the DS Studio doesn’t support class & function definitions that an error is drawn.  As in the previous translation, a custom node will be required.

Simply, copy and paste the following portion of script from page 73 into the Design Script Editor as follows:

  def makeSurf(p)

{

     p0 = p.Translate(-0.5, -0.5, 0);

     p1 = p.Translate(0.5, -0.5, 0);

     p2 = p.Translate(0.5, 0.5, 0);

     p3 = p.Translate(-0.5, 0.5, 0);

     pts = { {p0, p1}, {p3, p2} };

return = BSplineSurface.ByPoints(pts);

} 

Save the file, in this case the name makeSurf(p).ds, then add the file to DSS’s Library Box (+) (clicking on the +).

Chp-24_intersection_trim_selectTrim-add_perimeter#3_insert

Chp24_intersection_trim_selectTrim-add_perimeter#3_insert

The initial DSS translation is shown below.

Chp-24_intersection_trim_selectTrim-add_perimeter#3

Chp-24_intersection_trim_selectTrim-add_perimeter#3

Continuing on with the more detailed and defined translation with the renaming of the variables, identifying and referencing them with their corresponding nodes.

Chp-24_intersection_trim_selectTrim-add_perimeter#3a

Chp-24_intersection_trim_selectTrim-add_perimeter#3a

As a reminder, selecting the graphic window one can get an enlarged view of each snapshot.

Next is the “Node to Code” operation.

Chp-24_intersection_trim_selectTrim-add_perimeter#3b

Chp-24_intersection_trim_selectTrim-add_perimeter#3b

A little editing is desired.

Chp-24_intersection_trim_selectTrim-add_perimeter#3b-edited

Chp-24_intersection_trim_selectTrim-add_perimeter#3b-edited

The Graphic Window(s) that result from the script is shown below.

Chp-24_intersection_trim_selectTrim-add_perimeter#3a-Graphic Window

Chp-24_intersection_trim_selectTrim-add_perimeter#3a-Graphic Window

Reiterating, this was done on the stand-alone version of DesignScript, rather than as a plugin for AutoCad. The files are available for downloading from the Drop-Box links below.

2015_03_30-Chp-24_intersection_trim_selectTrim-add_perimeter#a3

2013_12_10-Chp-24_intersection_trim_selectTrim-add_perimeter#3

2015_03_30-Chp-24_intersection_trim_selectTrim-add_perimeter#3a

2015_03_30-Chp-24_intersection_trim_selectTrim-add_perimeter#3b

2015_03_30-Chp-24_intersection_trim_selectTrim-add_perimeter-ds#3

makesurf(p)

Thanks for looking.

T!M

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s