Hi,
i have problem with making my script working properly. I am trying to create quite easy 3D geometry. I wrote script for it which works fine, but just when i have some specific view. When i rotate view or zoom out and then run the script, script fails at some point - usually when selection is performed. I tried to solve problem with adding "plan" command at the start of a script, but the result is, that the script works on every second run if i run several times in a row without additional changing of view between runs.
Picture 1 shows model i am creating, picture 2 shows example of what happens, when i run script with different view (without setting plan in the script).
Why it is Autocad behaving like that, is there some explanation and solution?
Thanks in advance,
Vojtěch Hrubý
Solved! Go to Solution.
Hi,
i have problem with making my script working properly. I am trying to create quite easy 3D geometry. I wrote script for it which works fine, but just when i have some specific view. When i rotate view or zoom out and then run the script, script fails at some point - usually when selection is performed. I tried to solve problem with adding "plan" command at the start of a script, but the result is, that the script works on every second run if i run several times in a row without additional changing of view between runs.
Picture 1 shows model i am creating, picture 2 shows example of what happens, when i run script with different view (without setting plan in the script).
Why it is Autocad behaving like that, is there some explanation and solution?
Thanks in advance,
Vojtěch Hrubý
Solved! Go to Solution.
Solved by leeminardi. Go to Solution.
Check that object snap is not on. This can affect the script. YOu can use the following statement in a script to turn osnap off:
(setvar "osmode" 0)
Check that object snap is not on. This can affect the script. YOu can use the following statement in a script to turn osnap off:
(setvar "osmode" 0)
Thanks a lot for fast reply,
this didn't solved the problem, but it seem, that script is behaving from different views in less chaotic way than before, so it helped.
This is code i am using:
ATTDIA
0
FILEDIA
0
;HIDE DYNAMIC MODE OF SETTING PARAMETERS
DYNMODE
0
(setvar "osmode" 0)
;*******set world view****************************************
;PLAN
;W
;
;secondly delete all stuff created with previous script calls
erase
;select all
all
;erase selected
;-------------------------------------------------geometry deffinition-------------------------------
;all dimensions are in (mm)
;*******LETS DEFINE SOME VARIABLES****************************************
;define cake radius
(setq cakerad 50.845)
;*******CREATE A CYLINDER****************************************
; create bottom circle base
circle
;specify middle point
0,0,-20
;specify circle radius
!cakerad
;
; extrude selected circle (cylinder creation)
extrude
;select objects to extrude by fence (curve which passes through element, that should be selected)
c
;specify first fence point
0,10,-20
;specify next fence point
0,100,-20
;exit select
;specify height of cylinder (-40 because it starts in z = -20, 40 will give cylinder from z = -20 to z = -60)
40
;
;*******CREATE CENTRAL HOLE cylinder*****************************************
; create circle base
circle
;specify middle point
0,100,0
;specify circle radius
5
;
; rotate circle so it is in right plane
rotate3d
;select circle so it can be rotated
c
;specify first fence point
0,120,0
;specify next fence point
0,80,0
;exit select
;
;specify first point on axis
20,100,0
;specify second point on axis
-20,100,0
;specify rotation angle
90
;
;; extrude circle
extrude
;select circle to be extruded
c
;specify first fence point
20,100,0
;specify next fence point
-20,100,0
;exit select
;specify height of cylinder
-200
;
;*******DUPLICATE HOLE CYLINDER*******************************************
; duplicate selected cylinder
copy
c
;specify first fence point
20,100,0
;specify next fence point
-20,100,0
;exit select
;specify mode (multi copying)
m
;select base point
0,0,0
;select move point #1
20.34,0,0
;select move point #2
-20.34,0,0
;select move point #3
40.68,0,0
;select move point #4
-40.68,0,0
;exit select move point
;
;*******CREATING HOLES******************************************************
SUBTRACT
;select main cylinder
w
;specify first fence point
-60,-60,0
;specify next fence point
60,60,0
;exit select
;select hole cylinders
c
;specify first fence point
-50,70,0
;specify next fence point
50,80,0
;exit select
;
Thanks a lot for fast reply,
this didn't solved the problem, but it seem, that script is behaving from different views in less chaotic way than before, so it helped.
This is code i am using:
ATTDIA
0
FILEDIA
0
;HIDE DYNAMIC MODE OF SETTING PARAMETERS
DYNMODE
0
(setvar "osmode" 0)
;*******set world view****************************************
;PLAN
;W
;
;secondly delete all stuff created with previous script calls
erase
;select all
all
;erase selected
;-------------------------------------------------geometry deffinition-------------------------------
;all dimensions are in (mm)
;*******LETS DEFINE SOME VARIABLES****************************************
;define cake radius
(setq cakerad 50.845)
;*******CREATE A CYLINDER****************************************
; create bottom circle base
circle
;specify middle point
0,0,-20
;specify circle radius
!cakerad
;
; extrude selected circle (cylinder creation)
extrude
;select objects to extrude by fence (curve which passes through element, that should be selected)
c
;specify first fence point
0,10,-20
;specify next fence point
0,100,-20
;exit select
;specify height of cylinder (-40 because it starts in z = -20, 40 will give cylinder from z = -20 to z = -60)
40
;
;*******CREATE CENTRAL HOLE cylinder*****************************************
; create circle base
circle
;specify middle point
0,100,0
;specify circle radius
5
;
; rotate circle so it is in right plane
rotate3d
;select circle so it can be rotated
c
;specify first fence point
0,120,0
;specify next fence point
0,80,0
;exit select
;
;specify first point on axis
20,100,0
;specify second point on axis
-20,100,0
;specify rotation angle
90
;
;; extrude circle
extrude
;select circle to be extruded
c
;specify first fence point
20,100,0
;specify next fence point
-20,100,0
;exit select
;specify height of cylinder
-200
;
;*******DUPLICATE HOLE CYLINDER*******************************************
; duplicate selected cylinder
copy
c
;specify first fence point
20,100,0
;specify next fence point
-20,100,0
;exit select
;specify mode (multi copying)
m
;select base point
0,0,0
;select move point #1
20.34,0,0
;select move point #2
-20.34,0,0
;select move point #3
40.68,0,0
;select move point #4
-40.68,0,0
;exit select move point
;
;*******CREATING HOLES******************************************************
SUBTRACT
;select main cylinder
w
;specify first fence point
-60,-60,0
;specify next fence point
60,60,0
;exit select
;select hole cylinders
c
;specify first fence point
-50,70,0
;specify next fence point
50,80,0
;exit select
;
A few suggestions.
1. place a filedia 1 at the end!
2. Make sure the program always uses the same view. You can do this with:
-view
0
t
3. If you want to restore the view you started with use -view at the beginning and the end to save and restore.
4. Rather than create cylinders by extruding a circle and then extruding them (resulting in the potential error that the circle is not being selected), create the cylinders directly. Use the Axis Endpoint method which allows you to create the cylinder at any orientation without the need for rotate3d. For example,
cylinder
1,2,3 <---center of one end of the cylinder
a
4,5,6 <--- center of other end
A few suggestions.
1. place a filedia 1 at the end!
2. Make sure the program always uses the same view. You can do this with:
-view
0
t
3. If you want to restore the view you started with use -view at the beginning and the end to save and restore.
4. Rather than create cylinders by extruding a circle and then extruding them (resulting in the potential error that the circle is not being selected), create the cylinders directly. Use the Axis Endpoint method which allows you to create the cylinder at any orientation without the need for rotate3d. For example,
cylinder
1,2,3 <---center of one end of the cylinder
a
4,5,6 <--- center of other end
Thank you for all suggestions,
direct cylinder method is much more easier, script is still working on every second run, but that's something i can stand i guess 🙂
Thank you for all suggestions,
direct cylinder method is much more easier, script is still working on every second run, but that's something i can stand i guess 🙂
@Anonymous I am glad to have helped.
Feel free to post the latest version of the script if you would like it looked out as to why it only works every other time.
@Anonymous I am glad to have helped.
Feel free to post the latest version of the script if you would like it looked out as to why it only works every other time.
Can't find what you're looking for? Ask the community or share your knowledge.