create account

OpenSCAD教程之"创建基本3D物体" | OpenSCAD tutorial -- Create Primitive Solids by azcax

View this thread on: hive.blogpeakd.comecency.com
· @azcax · (edited)
$30.06
OpenSCAD教程之"创建基本3D物体" | OpenSCAD tutorial -- Create Primitive Solids
Summary: OpenSCAD (version 2015.03-2) is the open source software for creating solid 3D CAD models. It is available for Linux/UNIX, Windows and Mac OS X, and it is a programming Solid 3D CAD Modeller. In this tutorial I will show you how to create Primitive Solids.
The Primitive Solids include cube, sphere, cylinder and polyhedron, let's start...

1)方块(cube)

创建方块有2中语法,如下:
cube(size = [x,y,z], center = true/false);
cube(size =  x ,     center = true/false);

size指定方块的边长,center指定正方体的中心是否位于座标原点。如下图:

1.1)创建正方体:cube(size =  x ,     center = true/false);

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514870704/wbvgjtmlcessyuhy2syk.png)

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514870796/atz2sy5tmeopdccnenf0.png)

1.2)创建边长不一样的长方体:cube(size = [x,y,z], center = true/false);

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871046/vzbshcqgppuzobske2d9.png)

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871069/mlc3jq7sdlem6g7duh0y.png)

2)球体(sphere)

创建球体可以指定半径或者直径,语法如下:
sphere(r = x);
sphere(d = x);

指定半径创建:
![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871478/unps8rfvdudpcseyvhyg.png)

指定直径创建:
![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871535/iziekrl2oqivjynx6tyn.png)

3)圆柱(锥,台)体(cylinder)

语法如下,当r1=r2的时候,是圆柱体;r1或者r2一个为0的时候是圆锥体;r1和r2都不为0,并且不相等的时候为圆台体;center指定物体的中心是否位于座标原点。

cylinder(h = height, r1 = BottomRadius, r2 = TopRadius, center = true/false);

圆柱体:

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871872/is3gnjhyavbg6ucdw2fp.png)

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871899/uotqimrfgalqsvhcsx0h.png)

圆锥体:

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871953/khtjvi5rgzit7cnyalmy.png)

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871975/egoo1a8e6jahkyhucovt.png)

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872006/pvbdsekjtrn5pcwsegyg.png)

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872026/zhtu0x66kncw17n2hxun.png)

圆台体:

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872084/fp9t0s3nt12kwb82ygco.png)

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872102/nxhjtigjnzxinxfi28wk.png)

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872131/qdwthkhcpn5hcvriuqml.png)

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872152/aoxbacu14lq7xokuw4g9.png)

通过指定内置参数$fn的数值,可以创建棱柱,棱锥和棱台体:

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872476/c5wzny5utvybatl26sic.png)

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872431/p2hzujoe91zdmgecybdo.png)

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872497/aeelz6wl3r3by0eynpbw.png)

4)多面体(polyhedron)

语法如下,points指定多面体的顶点座标集,faces指定多面体每个面上顶点的索引,convexity指定在预览模式下与射线相交的最大面数。

polyhedron( points = [ [X0, Y0, Z0], [X1, Y1, Z1], ... ], faces = [ [P0, P1, P2, P3, ...], ... ], convexity = N);  

比如下面用多面体的方法创建长方体:

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514873530/fxfetokeor4kcrwmvhug.png)

![图片.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1514873574/ahpkvvjpwm4ll4fqxfxp.png)

<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@azcax/openscad-3d-or-openscad-tutorial-create-primitive-solids">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , ,
properties (23)
authorazcax
permlinkopenscad-3d-or-openscad-tutorial-create-primitive-solids
categoryutopian-io
json_metadata"{"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":1049088,"name":"openscad","full_name":"openscad/openscad","owner":{"login":"openscad","id":466370,"avatar_url":"https://avatars1.githubusercontent.com/u/466370?v=4","gravatar_id":"","url":"https://api.github.com/users/openscad","html_url":"https://github.com/openscad","followers_url":"https://api.github.com/users/openscad/followers","following_url":"https://api.github.com/users/openscad/following{/other_user}","gists_url":"https://api.github.com/users/openscad/gists{/gist_id}","starred_url":"https://api.github.com/users/openscad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openscad/subscriptions","organizations_url":"https://api.github.com/users/openscad/orgs","repos_url":"https://api.github.com/users/openscad/repos","events_url":"https://api.github.com/users/openscad/events{/privacy}","received_events_url":"https://api.github.com/users/openscad/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openscad/openscad","description":"OpenSCAD - The Programmers Solid 3D CAD Modeller ","fork":false,"url":"https://api.github.com/repos/openscad/openscad","forks_url":"https://api.github.com/repos/openscad/openscad/forks","keys_url":"https://api.github.com/repos/openscad/openscad/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openscad/openscad/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openscad/openscad/teams","hooks_url":"https://api.github.com/repos/openscad/openscad/hooks","issue_events_url":"https://api.github.com/repos/openscad/openscad/issues/events{/number}","events_url":"https://api.github.com/repos/openscad/openscad/events","assignees_url":"https://api.github.com/repos/openscad/openscad/assignees{/user}","branches_url":"https://api.github.com/repos/openscad/openscad/branches{/branch}","tags_url":"https://api.github.com/repos/openscad/openscad/tags","blobs_url":"https://api.github.com/repos/openscad/openscad/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openscad/openscad/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openscad/openscad/git/refs{/sha}","trees_url":"https://api.github.com/repos/openscad/openscad/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openscad/openscad/statuses/{sha}","languages_url":"https://api.github.com/repos/openscad/openscad/languages","stargazers_url":"https://api.github.com/repos/openscad/openscad/stargazers","contributors_url":"https://api.github.com/repos/openscad/openscad/contributors","subscribers_url":"https://api.github.com/repos/openscad/openscad/subscribers","subscription_url":"https://api.github.com/repos/openscad/openscad/subscription","commits_url":"https://api.github.com/repos/openscad/openscad/commits{/sha}","git_commits_url":"https://api.github.com/repos/openscad/openscad/git/commits{/sha}","comments_url":"https://api.github.com/repos/openscad/openscad/comments{/number}","issue_comment_url":"https://api.github.com/repos/openscad/openscad/issues/comments{/number}","contents_url":"https://api.github.com/repos/openscad/openscad/contents/{+path}","compare_url":"https://api.github.com/repos/openscad/openscad/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openscad/openscad/merges","archive_url":"https://api.github.com/repos/openscad/openscad/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openscad/openscad/downloads","issues_url":"https://api.github.com/repos/openscad/openscad/issues{/number}","pulls_url":"https://api.github.com/repos/openscad/openscad/pulls{/number}","milestones_url":"https://api.github.com/repos/openscad/openscad/milestones{/number}","notifications_url":"https://api.github.com/repos/openscad/openscad/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openscad/openscad/labels{/name}","releases_url":"https://api.github.com/repos/openscad/openscad/releases{/id}","deployments_url":"https://api.github.com/repos/openscad/openscad/deployments","created_at":"2010-11-03T20:25:33Z","updated_at":"2017-12-29T19:43:44Z","pushed_at":"2018-01-01T18:09:35Z","git_url":"git://github.com/openscad/openscad.git","ssh_url":"git@github.com:openscad/openscad.git","clone_url":"https://github.com/openscad/openscad.git","svn_url":"https://github.com/openscad/openscad","homepage":"openscad.org","size":48004,"stargazers_count":1910,"watchers_count":1910,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":508,"mirror_url":null,"archived":false,"open_issues_count":563,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0"},"forks":508,"open_issues":563,"watchers":1910,"default_branch":"master","score":156.42094},"pullRequests":[],"platform":"github","type":"tutorials","tags":["utopian-io","cad","model","3dprint","programming"],"links":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1514870704/wbvgjtmlcessyuhy2syk.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514870796/atz2sy5tmeopdccnenf0.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871046/vzbshcqgppuzobske2d9.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871069/mlc3jq7sdlem6g7duh0y.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871478/unps8rfvdudpcseyvhyg.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871535/iziekrl2oqivjynx6tyn.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871872/is3gnjhyavbg6ucdw2fp.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871899/uotqimrfgalqsvhcsx0h.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871953/khtjvi5rgzit7cnyalmy.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871975/egoo1a8e6jahkyhucovt.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872006/pvbdsekjtrn5pcwsegyg.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872026/zhtu0x66kncw17n2hxun.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872084/fp9t0s3nt12kwb82ygco.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872102/nxhjtigjnzxinxfi28wk.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872131/qdwthkhcpn5hcvriuqml.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872152/aoxbacu14lq7xokuw4g9.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872476/c5wzny5utvybatl26sic.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872431/p2hzujoe91zdmgecybdo.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872497/aeelz6wl3r3by0eynpbw.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514873530/fxfetokeor4kcrwmvhug.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514873574/ahpkvvjpwm4ll4fqxfxp.png"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1514870704/wbvgjtmlcessyuhy2syk.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514870796/atz2sy5tmeopdccnenf0.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871046/vzbshcqgppuzobske2d9.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871069/mlc3jq7sdlem6g7duh0y.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871478/unps8rfvdudpcseyvhyg.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871535/iziekrl2oqivjynx6tyn.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871872/is3gnjhyavbg6ucdw2fp.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871899/uotqimrfgalqsvhcsx0h.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871953/khtjvi5rgzit7cnyalmy.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514871975/egoo1a8e6jahkyhucovt.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872006/pvbdsekjtrn5pcwsegyg.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872026/zhtu0x66kncw17n2hxun.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872084/fp9t0s3nt12kwb82ygco.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872102/nxhjtigjnzxinxfi28wk.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872131/qdwthkhcpn5hcvriuqml.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872152/aoxbacu14lq7xokuw4g9.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872476/c5wzny5utvybatl26sic.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872431/p2hzujoe91zdmgecybdo.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514872497/aeelz6wl3r3by0eynpbw.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514873530/fxfetokeor4kcrwmvhug.png","https://res.cloudinary.com/hpiynhbhq/image/upload/v1514873574/ahpkvvjpwm4ll4fqxfxp.png"],"moderator":{"account":"manishmike10","reviewed":true,"pending":false,"flagged":false}}"
created2018-01-02 06:19:09
last_update2018-01-07 00:41:21
depth0
children4
last_payout2018-01-09 06:19:09
cashout_time1969-12-31 23:59:59
total_payout_value21.145 HBD
curator_payout_value8.919 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,433
author_reputation97,519,363,597
root_title"OpenSCAD教程之"创建基本3D物体" | OpenSCAD tutorial -- Create Primitive Solids"
beneficiaries
0.
accountutopian.pay
weight2,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id26,499,282
net_rshares3,096,108,519,877
author_curate_reward""
vote details (14)
@manishmike10 ·
Thank you for the contribution. It has been approved.

You can contact us on [Discord](https://discord.gg/UCvqCsx).
**[[utopian-moderator]](https://utopian.io/moderators)**
👍  
properties (23)
authormanishmike10
permlinkre-azcax-openscad-3d-or-openscad-tutorial-create-primitive-solids-20180103t192552449z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-03 19:25:54
last_update2018-01-03 19:25:54
depth1
children1
last_payout2018-01-10 19:25:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length172
author_reputation20,399,732,899,016
root_title"OpenSCAD教程之"创建基本3D物体" | OpenSCAD tutorial -- Create Primitive Solids"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id26,851,570
net_rshares618,945,115
author_curate_reward""
vote details (1)
@azcax ·
@manishmike10, thanks!
properties (22)
authorazcax
permlinkre-manishmike10-re-azcax-openscad-3d-or-openscad-tutorial-create-primitive-solids-20180103t235821080z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["manishmike10"],"app":"steemit/0.1"}
created2018-01-03 23:58:09
last_update2018-01-03 23:58:09
depth2
children0
last_payout2018-01-10 23:58:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length22
author_reputation97,519,363,597
root_title"OpenSCAD教程之"创建基本3D物体" | OpenSCAD tutorial -- Create Primitive Solids"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id26,897,519
net_rshares0
@steem-network ·
<html>
<p>Congratulations <a href="/@azcax" target="_blank">@azcax</a>, you have decided to take the next big step with your first post! The Steem Network Team wishes you a great time among this awesome community.</p>
<hr>
<div class="pull-left"><img src="https://steemitimages.com/DQmaAdLUJ3yaSkmcmWECWyPGPWcjfbCoZ8Tu4RM6H4DbjCi/steem-network-thumbs-up.gif" alt="Thumbs up for Steem Network´s strategy" title="I suggest Steem Network´s strategy" width="320" height="222"></div>
<h1>The proven road to boost your personal success in this amazing Steem Network</h1>
<p>Do you already know that awesome content will get great profits by following these <a href="/steem-network/@steem-network/spread-your-posts-through-this-proven-strategy-and-get-great-profits-in-return--for-posts-created-at-2018-01-02" target="_blank" alt="Steem Network" title="Follow Steem Network´s suggestions to boost your success">simple steps</a>, that have been worked out by experts?</p>
</html>
properties (22)
authorsteem-network
permlinkre-openscad-3d-or-openscad-tutorial-create-primitive-solids-20180102t094335
categoryutopian-io
json_metadata"{"tags": ["steem-network"], "users": ["steem-network", "azcax"], "image": ["https://steemitimages.com/DQmaAdLUJ3yaSkmcmWECWyPGPWcjfbCoZ8Tu4RM6H4DbjCi/steem-network-thumbs-up.gif"], "links": ["/@azcax", "/steem-network/@steem-network/spread-your-posts-through-this-proven-strategy-and-get-great-profits-in-return--for-posts-created-at-2018-01-02"], "community": "steem-network", "app": "steem-network/1.0.1", "format": "html"}"
created2018-01-02 09:43:36
last_update2018-01-02 09:43:36
depth1
children0
last_payout2018-01-09 09:43:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length971
author_reputation-788,969,433,247
root_title"OpenSCAD教程之"创建基本3D物体" | OpenSCAD tutorial -- Create Primitive Solids"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id26,525,803
net_rshares0
@utopian-io ·
$0.04
### Hey @azcax I am @utopian-io. I have just upvoted you!
#### Achievements
- You have less than 500 followers. Just gave you a gift to help you succeed!
- This is your first accepted contribution here in Utopian. Welcome!
#### Suggestions
- Contribute more often to get higher and higher rewards. I wish to see you often!
- Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!
#### Get Noticed!
- Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!
#### Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER!
- <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a>
- <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a>
- Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a>

[![mooncryption-utopian-witness-gif](https://steemitimages.com/DQmYPUuQRptAqNBCQRwQjKWAqWU3zJkL3RXVUtEKVury8up/mooncryption-s-utopian-io-witness-gif.gif)](https://steemit.com/~witnesses)

**Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
👍  
properties (23)
authorutopian-io
permlinkre-azcax-openscad-3d-or-openscad-tutorial-create-primitive-solids-20180104t071339608z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-04 07:13:39
last_update2018-01-04 07:13:39
depth1
children0
last_payout2018-01-11 07:13:39
cashout_time1969-12-31 23:59:59
total_payout_value0.034 HBD
curator_payout_value0.005 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,522
author_reputation152,955,367,999,756
root_title"OpenSCAD教程之"创建基本3D物体" | OpenSCAD tutorial -- Create Primitive Solids"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id26,967,702
net_rshares3,739,206,761
author_curate_reward""
vote details (1)