View Full Version : Extrude Items Which Were Arrayed
BoKirra
2008-03-19, 04:41 AM
Hi Everyone,
With my flange routine, I want to make flange to 3D with command "extrude" but no success.
What I did was
1) Drawn a flange OD;
2) Drawn a flange hole then ARRAYING the hole to a total of 6 items;
I was able to define the original hole by using the following:
(setq HOLE01 (entlast))
(command "-array" HOLE01 "" "P" InsertPoint 6 "" "")
3) Now I got a 2D flange;
4) Then next line would "extrude" flange & holes to make a 25mm thickness;
The PROBLEM was that I was not able to define the other 5 holes, nor select them.
5) At the end I would combine the 7 solids created (1 flange & 6 holes) by using command "subtract".
Can anyone help?
Thanks in advance.
irneb
2008-03-19, 06:47 AM
Have you tried getting an entity name using the entlast method, each time just after creating the outline & holes?
For the array, get the entlast for the 1st hole drawn. Then after the array, use entnext to get the rest of the arrayed holes. These you can store in a selection sec with ssadd so you can pass them in one go to the Extrude command.
You'll probably need to use the entlast - entnext idea to get hold of the solids created as well. Say extrude the outline, entlast, extrude the holes, entnext from the flange (use ssadd until entnext gives nil), then Subtract.
BoKirra
2008-03-20, 03:37 AM
Have you tried getting an entity name using the entlast method, each time just after creating the outline & holes?
For the array, get the entlast for the 1st hole drawn. Then after the array, use entnext to get the rest of the arrayed holes. These you can store in a selection sec with ssadd so you can pass them in one go to the Extrude command.
You'll probably need to use the entlast - entnext idea to get hold of the solids created as well. Say extrude the outline, entlast, extrude the holes, entnext from the flange (use ssadd until entnext gives nil), then Subtract.
Thanks, irneb.
I'll try it aftet the Easter Holiday.
BoKirra
2008-03-25, 02:21 AM
irneb,
I've tried but with no success.
Could you please give me a help?
The following is my code. I removed the set layer function for clarity.
Thanks.
;=========================
(defun DEG (A) (* pi (/ A 180.0)))
;=========================
(defun C:FG (/ Point1 Entity1 Entity2)
(setq IPoint (getpoint ""))
(setq Point1 (polar IPoint (DEG 90) 75))
(command "circle" IPoint "d" 200)
(setq Entity1 (entlast))
(command "circle" Point1 "d" 20)
(setq Entity2 (entlast))
(command "-array" Entity2 "" "P" IPoint 6 "" "")
(command "extrude" Entity1 Entity2 "" 10 "")
(command "subtract" Entity1 "" Entity2 "")
(princ)
)
;;;;; END of Code
RobertB
2008-03-25, 08:39 PM
Extrude creates a new object. You are not getting the new objects for the subtract command.
Adesu
2008-03-26, 02:25 AM
Hi ke.li,
test this code
(defun DEG (A)
(* pi (/ A 180.0))
)
(defun C:FG (/ cnt entity1 entity2 entity3 ipoint point1 ss ssl ssn)
(setq IPoint '(0 0 0)) ; (getpoint "\nPick any location: "))
(setq Point1 (polar IPoint (DEG 90) 75))
(command "circle" IPoint "d" 200)
(setq Entity1 (entlast))
(command "extrude" Entity1 "" 10 "")
(setq Entity3 (entlast))
(command "circle" Point1 "d" 20)
(setq Entity2 (entlast))
(command "-array" Entity2 "" "P" IPoint 6 "" "")
(setq ss (ssget "x" '((0 . "CIRCLE") (-4 . "=") (40 . 10))))
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(command "extrude" ssn "" 10 "")
(command "subtract" Entity3 "" "l" "")
(setq cnt (1+ cnt))
) ; repeat
;(command "subtract" Entity1 "" Entity2 "")
(princ)
)
irneb,
I've tried but with no success.
Could you please give me a help?
The following is my code. I removed the set layer function for clarity.
Thanks.
;=========================
(defun DEG (A) (* pi (/ A 180.0)))
;=========================
(defun C:FG (/ Point1 Entity1 Entity2)
(setq IPoint (getpoint ""))
(setq Point1 (polar IPoint (DEG 90) 75))
(command "circle" IPoint "d" 200)
(setq Entity1 (entlast))
(command "circle" Point1 "d" 20)
(setq Entity2 (entlast))
(command "-array" Entity2 "" "P" IPoint 6 "" "")
(command "extrude" Entity1 Entity2 "" 10 "")
(command "subtract" Entity1 "" Entity2 "")
(princ)
)
;;;;; END of Code
BoKirra
2008-03-27, 01:59 AM
Hi, Adesu
Thanks for your help.
It works well & it is what I am looking for.
(defun DEG (A)
(* pi (/ A 180.0))
)
(defun C:FG (/ cnt entity1 entity2 entity3 ipoint point1 ss ssl ssn)
(setq IPoint '(0 0 0)) ; (getpoint "\nPick any location: "))
(setq Point1 (polar IPoint (DEG 90) 75))
(command "circle" IPoint "d" 200)
(setq Entity1 (entlast))
(command "extrude" Entity1 "" 10 "")
(setq Entity3 (entlast))
(command "circle" Point1 "d" 20)
(setq Entity2 (entlast))
(command "-array" Entity2 "" "P" IPoint 6 "" "")
(setq ss (ssget "x" '((0 . "CIRCLE") (-4 . "=") (40 . 10))))
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(command "extrude" ssn "" 10 "")
(command "subtract" Entity3 "" "l" "")
(setq cnt (1+ cnt))
) ; repeat
;(command "subtract" Entity1 "" Entity2 "")
(princ)
)
BoKirra
2008-03-27, 04:17 AM
Hi, Adesu
Could you please explain what do the numbers mean in the following line in your code:
(0 . "CIRCLE") = ?
(-4 . "=") = ?
(40 . 10) = ? - I know "10" is the circle radius. How to make it as a variable?
Thanks again
...
(setq ss (ssget "x" '((0 . "CIRCLE") (-4 . "=") (40 . 10))))
...
BoKirra
2008-03-31, 02:45 AM
Another question to ALL,
Now I wish to add the following functions to the code attached:
Select different flange OD, Hole & Pipe OD by entering their sizes command line;
It can be assumed that flange thickness = 10mm & Number of Holes = 6
Your helps would be greatly appreciated.
(defun DEG (A)
(* pi (/ A 180.0))
)
(defun C:FG (/ cnt entity1 entity2 entity3 entity4 IPoint Point1 ss ssl ssn)
(setq IPoint (getpoint "\nSelect Insert Point: "))
(setq Point1 (polar IPoint (DEG 90) 75))
(command "circle" IPoint "d" 200)
(setq Entity1 (entlast))
(command "extrude" Entity1 "" 10 "")
(setq Entity3 (entlast))
(command "circle" Point1 "d" 20)
(setq Entity2 (entlast))
(command "-array" Entity2 "" "P" IPoint 6 "" "")
(setq ss (ssget "x" '((0 . "CIRCLE") (-4 . "=") (40 . 10))))
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(command "extrude" ssn "" 10 "")
(command "subtract" Entity3 "" "l" "")
(setq cnt (1+ cnt))
) ; repeat
(setq Entity4 (entlast))
(command "chprop" Entity4 "" "la" "Pipeline" "")
(princ)
)
Adesu
2008-04-01, 02:10 AM
You are welcome.
Hi, Adesu
Thanks for your help.
It works well & it is what I am looking for.
Adesu
2008-04-01, 02:19 AM
if you want know about filter list, type "vlide" at command prompt, after visual editor open, click help file > autolisp developer's guide > using autolisp to manipulate autocad object > selection set filter lists.
And open too DXF Reference > DXF Format > Group Codes in Numerical Order.
I hope this can help you
Hi, Adesu
Could you please explain what do the numbers mean in the following line in your code:
(0 . "CIRCLE") = ?
(-4 . "=") = ?
(40 . 10) = ? - I know "10" is the circle radius. How to make it as a variable?
Thanks again
Adesu
2008-04-01, 02:29 AM
Here your code after I revised,
(defun DEG (A)
(* pi (/ A 180.0))
)
(defun C:FG (/ cnt entity1 entity2 entity3 entity4
ipoint lay nlay point1 ss ssl ssn)
(setq IPoint (getpoint "\nSelect Insert Point: "))
(setq Point1 (polar IPoint (DEG 90) 75))
(command "circle" IPoint "d" 200)
(setq Entity1 (entlast))
(command "extrude" Entity1 "" 10 "")
(setq Entity3 (entlast))
(command "circle" Point1 "d" 20)
(setq Entity2 (entlast))
(command "-array" Entity2 "" "P" IPoint 6 "" "")
(setq ss (ssget "x" '((0 . "CIRCLE") (-4 . "=") (40 . 10))))
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(command "extrude" ssn "" 10 "")
(command "subtract" Entity3 "" "l" "")
(setq cnt (1+ cnt))
) ; repeat
(setq Entity4 (entlast))
(setq nlay "Pipeline")
(setq lay (getvar "clayer"))
(if
(/= lay nlay)
(command "_layer" "m" nlay "c" 7 "" "")
) ; if
(command "chprop" Entity4 "" "la" "Pipeline" "")
(princ)
) ; defun
Another question to ALL,
Now I wish to add the following functions to the code attached:
Select different flange OD, Hole & Pipe OD by entering their sizes command line;
It can be assumed that flange thickness = 10mm & Number of Holes = 6
Your helps would be greatly appreciated.
(defun DEG (A)
(* pi (/ A 180.0))
)
(defun C:FG (/ cnt entity1 entity2 entity3 entity4 IPoint Point1 ss ssl ssn)
(setq IPoint (getpoint "\nSelect Insert Point: "))
(setq Point1 (polar IPoint (DEG 90) 75))
(command "circle" IPoint "d" 200)
(setq Entity1 (entlast))
(command "extrude" Entity1 "" 10 "")
(setq Entity3 (entlast))
(command "circle" Point1 "d" 20)
(setq Entity2 (entlast))
(command "-array" Entity2 "" "P" IPoint 6 "" "")
(setq ss (ssget "x" '((0 . "CIRCLE") (-4 . "=") (40 . 10))))
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(command "extrude" ssn "" 10 "")
(command "subtract" Entity3 "" "l" "")
(setq cnt (1+ cnt))
) ; repeat
(setq Entity4 (entlast))
(command "chprop" Entity4 "" "la" "Pipeline" "")
(princ)
)
BoKirra
2008-04-01, 04:40 AM
Thanks again.
But now I need more helps for this code.
By using this routine, I wish I can be able to draw various sizes of flange by entering following dimensions in command prompt (flange thickness can be 10mm all time, however):
1) Flange OD diameter;
2) Flange hole diameter;
3) Pipe OD diameter.
Rather than the OD=200mm & Hole=20mm fixed by the code.
cheers
Here your code after I revised,
(defun DEG (A)
(* pi (/ A 180.0))
)
(defun C:FG (/ cnt entity1 entity2 entity3 entity4
ipoint lay nlay point1 ss ssl ssn)
(setq IPoint (getpoint "\nSelect Insert Point: "))
(setq Point1 (polar IPoint (DEG 90) 75))
(command "circle" IPoint "d" 200)
(setq Entity1 (entlast))
(command "extrude" Entity1 "" 10 "")
(setq Entity3 (entlast))
(command "circle" Point1 "d" 20)
(setq Entity2 (entlast))
(command "-array" Entity2 "" "P" IPoint 6 "" "")
(setq ss (ssget "x" '((0 . "CIRCLE") (-4 . "=") (40 . 10))))
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(command "extrude" ssn "" 10 "")
(command "subtract" Entity3 "" "l" "")
(setq cnt (1+ cnt))
) ; repeat
(setq Entity4 (entlast))
(setq nlay "Pipeline")
(setq lay (getvar "clayer"))
(if
(/= lay nlay)
(command "_layer" "m" nlay "c" 7 "" "")
) ; if
(command "chprop" Entity4 "" "la" "Pipeline" "")
(princ)
) ; defun
Adesu
2008-04-03, 10:05 AM
Maybe you want as like this code, but sorry it's not yet tested
;(defun DEG (A)
; (* pi (/ A 180.0))
; ) ; defun
(defun C:FG (/ cnt entity1 entity2 entity3 entity4
hole ipoint lay nlay od point1 ss ssl ssn)
(setq IPoint (getpoint "\nSelect Insert Point<0,0,0>: "))
(if (= IPoint nil)(setq IPoint '(0 0 0)))
;(setq Point1 (polar IPoint (DEG 90) 75))
(setq Point1 (polar IPoint (* pi 0.5) 75))
(setq OD (getdist "\nEnter Flange OD diameter<200>: "))
(if (= OD nil)(setq OD 200))
(command "circle" IPoint "d" OD)
(setq Entity1 (entlast))
(command "extrude" Entity1 "" 10 "")
(setq Entity3 (entlast))
(setq hole (getdist "\nEnter Flange hole diameter<20>: "))
(if (= hole nil)(setq hole 20))
(command "circle" Point1 "d" hole)
(setq Entity2 (entlast))
(command "-array" Entity2 "" "P" IPoint 6 "" "")
(setq ss (ssget "x" '((0 . "CIRCLE") (-4 . "=") (40 . 10))))
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(command "extrude" ssn "" 10 "")
(command "subtract" Entity3 "" "l" "")
(setq cnt (1+ cnt))
) ; repeat
(setq Entity4 (entlast))
(setq nlay "Pipeline")
(setq lay (getvar "clayer"))
(if
(/= lay nlay)
(command "_layer" "m" nlay "c" 7 "" "")
) ; if
(command "chprop" Entity4 "" "la" "Pipeline" "")
(princ)
) ; defun
Thanks again.
But now I need more helps for this code.
By using this routine, I wish I can be able to draw various sizes of flange by entering following dimensions in command prompt (flange thickness can be 10mm all time, however):
1) Flange OD diameter;
2) Flange hole diameter;
3) Pipe OD diameter.
Rather than the OD=200mm & Hole=20mm fixed by the code.
cheers
BoKirra
2008-04-04, 08:53 AM
Thanks for your help, again.
But I found there is a problem. It can't subtract solids when flange hole dia /= 20mm.
Another thought is that all other circles whcih equals to the flange hole dia will disappear in the drawing, when the code executes. Because ssget is set to "x" (ie. it selects all entities in the database) in the following line.
I think the flange hole radius of "10" is to be set to a variable & ssget is to be set to other selection methods neither than "x" in the line below in your code:
Maybe you want as like this code, but sorry it's not yet tested
...
(setq ss (ssget "x" '((0 . "CIRCLE") (-4 . "=") (40 . 10))))
...
I can fix the other errors without this.
Could you please check it?
Thanks.
Adesu
2008-04-07, 02:11 AM
First said thanks for your correction.
This code you should revise, change it
(setq ss (ssget "x" '((0 . "CIRCLE") (-4 . "=") (40 . 10))))
to
(setq ss (ssget "x" '((0 . "CIRCLE"))))
Thanks for your help, again.
But I found there is a problem. It can't subtract solids when flange hole dia /= 20mm.
Another thought is that all other circles whcih equals to the flange hole dia will disappear in the drawing, when the code executes. Because ssget is set to "x" (ie. it selects all entities in the database) in the following line.
I think the flange hole radius of "10" is to be set to a variable & ssget is to be set to other selection methods neither than "x" in the line below in your code:
I can fix the other errors without this.
Could you please check it?
Thanks.
BoKirra
2008-04-07, 05:52 AM
Thanks again.
With the following replacement of your suggestion,
(setq ss (ssget "x" '((0 . "CIRCLE"))))
the execution hung up and the text window shows
Command: fg
Select Insert Point:
Enter Flange OD diameter: 250
Enter Flange hole diameter <20>: 25
Enter Flange Thickness: 10
Select solids and regions to subtract from ..
Select solids and regions to subtract ..
Unknown command "FG". Press F1 for help.
Select solids and regions to subtract from ..
Select solids and regions to subtract ..
Unknown command "FG". Press F1 for help.
Select solids and regions to subtract from ..
Select solids and regions to subtract ..
Unknown command "FG". Press F1 for help.
Select solids and regions to subtract from ..
Select solids and regions to subtract ..
Unknown command "FG". Press F1 for help.
Select solids and regions to subtract from ..
Select solids and regions to subtract ..
Unknown command "FG". Press F1 for help.
Select solids and regions to subtract from ..
Select solids and regions to subtract ..
Unknown command "FG". Press F1 for help.
Nothing selected.
10.000000
When I restore the original line
(setq ss (ssget "x" '((0 . "CIRCLE") (-4 . "=") (40 . 10))))
and enter a hole diameter of 20mm, the code works perfectly.
I think there is a problem with this line:
(setq ss (ssget "x" '((0 . "CIRCLE"))))
Please advise.
Adesu
2008-04-08, 02:21 AM
Sorry last time code more error, but try again this code
(defun c:fg (/ cnt entity1 entity2 entity3 entity4 hole ipoint lay nlay od om ort point1 ss ssl ssn)
(setq om (getvar "osmode"))
(if
(not (= om 0))
(setvar "osmode" 0)
) ; if
(setq ort (getvar "orthomode"))
(if
(not (= ort 0))
(setvar "orthomode" 0)
) ; if
(setq IPoint (getpoint "\nSelect Insert Point<0,0,0>: "))
(if (= IPoint nil)(setq IPoint '(0 0 0)))
(setq Point1 (polar IPoint (* pi 0.5) 75))
(setq OD (getdist "\nEnter Flange OD diameter<200>: "))
(if (= OD nil)(setq OD 200))
(command "circle" IPoint "d" OD)
(setq Entity1 (entlast))
(command "extrude" Entity1 "" 10 "")
(setq Entity3 (entlast))
(setq hole (getdist "\nEnter Flange hole diameter<20>: "))
(if (= hole nil)(setq hole 20))
(command "circle" Point1 "d" hole)
(setq Entity2 (entlast))
(command "-array" Entity2 "" "P" IPoint 6 "" "")
(setq ss (ssget "x" (list (cons 0 "CIRCLE")(cons 40 (/ hole 2.0)))))
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(command "extrude" ssn "" 10 "")
(command "subtract" Entity3 "" "l" "")
(setq cnt (1+ cnt))
) ; repeat
(setq Entity4 (entlast))
(setq nlay "Pipeline")
(setq lay (getvar "clayer"))
(if
(/= lay nlay)
(command "_layer" "m" nlay "c" 7 "" "")
) ; if
(command "chprop" Entity4 "" "la" "Pipeline" "")
(command "_vpoint" "r" 275 35 "")
(setvar "osmode" om)
(setvar "orthomode" ort)
(princ)
) ; defun
Thanks again.
With the following replacement of your suggestion,
(setq ss (ssget "x" '((0 . "CIRCLE"))))
the execution hung up and the text window shows
When I restore the original line
(setq ss (ssget "x" '((0 . "CIRCLE") (-4 . "=") (40 . 10))))
and enter a hole diameter of 20mm, the code works perfectly.
I think there is a problem with this line:
(setq ss (ssget "x" '((0 . "CIRCLE"))))
Please advise.
BoKirra
2008-04-08, 11:36 AM
It works now. Thanks!
Again, the following line delects all circles which diameter = hole in the entire drawing when it draws a 3D flange.
Can this problem be sovled, please?
Thanks for your time & help.
Sorry last time code more error, but try again this code
...
(setq ss (ssget "x" (list (cons 0 "CIRCLE")(cons 40 (/ hole 2.0)))))
...
Adesu
2008-04-09, 01:53 AM
you are welcome.
It works now. Thanks!
Again, the following line delects all circles which diameter = hole in the entire drawing when it draws a 3D flange.
Can this problem be sovled, please?
Thanks for your time & help.
BoKirra
2008-04-09, 05:17 AM
Don't worry, I fixed it.
It works. Thanks!
Again, the following line delects all circles which diameter = hole in the entire drawing when it draws a 3D flange.
Can this problem be sovled, please?
Sorry last time code more error, but try again this code
...
(setq ss (ssget "x" (list (cons 0 "CIRCLE")(cons 40 (/ hole 2.0)))))
...
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.