Jump to content

Recommended Posts

Posted

I'm writing a script to make a coffee mug (for my office project!), and everything was going smoothly until I made an arc for my handle. I have checked and rechecked my script and am baffled why I have an invalid point. If I make an arc using my script formula (but not the actual script) there is not a problem, but when it comes to the last point of my arc (when running the script) it says it is an invalid point. Any thoughts?

From command line after running my script:

Command: arc

Specify start point of arc or

: 4,1

 

Specify second point of arc or [Center/End]: c

Specify center point of arc: 4,2.25

 

Specify end point of arc or [Angle/chord Length]: 4,3.5

*Invalid*

 

My script

-units

4

4

1

0

 

 

-layer

m

mug

c

blue

 

s

mug

 

rectangle

0,0

4,4

circle

2,8

2

arc

4,1

c

4,2.25

4,3.5

Posted

I don't know. Tried it on both my machines, one on 2007, the other running 2010 and your script works on both of them.

 

My only suggestion is to make sure you are using a simple text editor like notepad. MS Word or Wordpad sometimes does not produce a pure ascii text file. I highlited all the text in your post starting with -units down, pasted in notepad and saved it as "mug. scr". Dont forget to change the "save as type" to "all files" and you shouldn't have any problems

Posted

I am using notepad and I tried turning off osnaps and I made sure it was saved to all files and I am still getting the error. It will draw everything up to the arc. New clue, I get the error on AutoCAD Architectural 2011 student version, but I just tried it on my Civil 2011 version and it works! I am baffled, it doesn't make sense to get that error.

Posted

I just realized that when the script runs on my civil version it is making the arc the wrong size (coordinates). Everything else, (circle rec) is as it should be but the id points for the arc are 4,0 and 4,4 and the center is at 4,2. It should be, from the script, 4,1; 4,3.5 and the center at 4,2.

 

My UCS is set to world.

Posted
mug based on your script:

[ATTACH]26344[/ATTACH]

 

Where's the coffee?

Posted
Where's the coffee?

 

was making a fresh pot. here ya go

mug.JPG

Posted

That is nice!

 

Thanks everyone, I still can't get mine to work. I still get the error in the Architectural version and the handle is the wrong size when I run the script in Civil (but it does run). I'll show it to my teacher on Saturday and see if I get the same issues with the school computers.

 

But to carry on with the script, can I write script to extrude my cup? It seems that this may not work. I also tried a cylinder, but that will require subtraction and a selection, and a solid edit shelling requires a selection. Our assignment is to write a script for a 3d object, maybe I should find a different object...

Posted

I drew what you saw using the "revolve" and "union" commands. I started out with what your script does and modified the shape as you see below. Draw what basically looks like an L, whatever thickness you want the cup to be. pedit it into a closed polyline, (or draw it that way to start with!). Revolve it around the center of the cup 360°. Then offset the arc that makes the handle, close the two open ends to make it a closed poly line and revolve it around the same center point 15°. Union the handle to the cup, fillet the sharp edges and you're done.

 

setup.JPG

Posted

The problem I'm having is turning that into script. When I am writing it I can't select on an object, I have to be able to type into the command line my selection.

Posted

Try drawing the L shape first then use a "revolve all" to select. Then have it draw the shape for the handle, and do another revolve all. It will reject the solid you already did. Then do the union the same way. Just make sure there are no other objects in the drawing, because it will revolve "all" that is revolvable (is that a word?).

Posted

got to playing around with rendering the mug

mug.jpg

Posted

Good morning; I'm back! I really am trying to do this on my own but I am so glad that you are all there. The idea to revolve my mug was great, but then I hit a snag using the sweep command to make my handle. Once again I can't select to write my script. So then I came up with what I thought was a great idea to make a Torus as my handle and then slice it off. Once again I can't select my object. Does anyone have any other ideas, or have I used up my quota for this topic! Here is my latest script with the torus and section plane.

-units

4

4

1

0

 

 

-layer

n

mug

c

yellow

 

s

mug

 

dimlunit

4

pline

2,0

4,0

4,5

3.75,5

3.75,.25

2,.25

2,0

 

 

 

 

revolve

all

 

2,0

2,5

 

 

 

-layer

m

handle

c

red

handle

 

torus

4,2.5

2

.25

sectionplane

4,0

4,5

Posted
Good morning; I'm back! I really am trying to do this on my own but I am so glad that you are all there. The idea to revolve my mug was great, but then I hit a snag using the sweep command to make my handle. Once again I can't select to write my script. So then I came up with what I thought was a great idea to make a Torus as my handle and then slice it off. Once again I can't select my object. Does anyone have any other ideas, or have I used up my quota for this topic! Here is my latest script with the torus and section plane.

 

You didn't like my suggestion for revolving the handle?

Posted

I love your suggestion! I just didn't read it right the first time so I got off on my other method. So, I went back to your idea and after many tweaks (scripts are not fun!), I have a beautiful coffee mug with filleted edges too! It is not rendered sitting on a table filled with coffee and a dollop of cream- I may have to work on that! So, Thank you all very much!!

Posted

Happy to help, and I'm glad you got it to work. The rendering was the first one I'd done in years, and had to figure out how that all works again.

 

Scripts for drawing stuff are in my opinion a little on the "more trouble than they are worth" side. A script does exactly the same thing every time unless you edit it before you run it. If you are going to draw the same thing over and over again, draw it once, save it as a block and insert it when you need it.

 

I do use scripts for repetitive editing tasks however. I have a scipt saved that will turn the limits off, do a zoom extents, run purge all 5 times (just to make sure it gets it all) and a save. I have another customer that has hundreds of standard detail drawings and part drawings. Every time they send out an update, I get a zip file full of this stuff. The first thing I do is run a script that erases thier titleblock (it leaves the information, just gets rid of the lines) and thier company logo. It purges, zooms extents and saves. When I did this the first time, I reduced the amount of storage space required for thier stuff by 75%.

 

Good luck with your class!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...