Extrude all polylines from a given parameter

Anonymous

Extrude all polylines from a given parameter

Anonymous
Not applicable

Hi,

 

I have many polylines in my drawing at elevation 0. for each polylines I have a 2 parameters, one for the base of elevation and one for the height of elevation. 

 

I just start to creat a list of all polylines, but i can't creat just one to try.. Someone can help me? I also doesnt find how can set the base of elevation in the elevation parameter..

 

(defun c:xtrude (/ polyl)

(setq polyl (ssget "_X" '((0 . "*POLYLINE"))))
(command "_extrude" (nth 12 polyl) "50") ;example

)

 

Thanks for all!

0 Likes
Reply
Accepted solutions (1)
2,019 Views
19 Replies
Replies (19)

CodeDing
Advisor
Advisor

@Anonymous ,

 

Can you perhaps post a sample drawing for us? That would give an idea of what you're working with.

Also, here's some notes about your provided code:

 

(defun c:xtrude (/ polyl)
;this ssget is getting ALL polylines (2D and 3D). Do you use both types?
(setq polyl (ssget "_X" '((0 . "*POLYLINE"))))

;the (nth ...) function accesses a List. Our variable ..polyl... is a Selection Set.

;to get an entity from a selection set, we use the (ssname ...) function

;Normally, we have more than 1 entity in a selection set, so we would loop through the selection set.

;We can see how many entities are in a selection set with the (sslength ...) function.
(command "_extrude" (nth 12 polyl) "50") ;example

;to extrude ONLY the First entity in our selection set, it would go something like this:

; (command "_.EXTRUDE" (ssname polyl 0) 50.0)
)

 

 

Best,

~DD

0 Likes

Sea-Haven
Mentor
Mentor

SSGET can retrieve the data set not in the order you think, so how would you know which is the 12th pline.  If you want to do extrude 50 then pick pick etc easy done and may be a safer way. 

0 Likes

ronjonp
Advisor
Advisor

Maybe this will give you some ideas:

(defun c:foo (/ _extrude ex o s sp)
  ;; RJP Ā» 2020-03-10
  (defun _extrude (sp o h tp / e r)
    (and (= 'list (type (setq e (vl-catch-all-apply 'vlax-invoke (list sp 'addregion (list o))))))
	 (setq r (vla-addextrudedsolid sp (car e) h tp))
	 (vl-catch-all-apply 'vla-delete (list e))
    )
    r
  )
  ;; Filter lwpolylines on unlocked layers and at zero elevation and are closed
  (if (setq s (ssget "_:L" '((0 . "lwpolyline") (38 . 0) (-4 . "&=") (70 . 1))))
    (progn ;; Get current space for extrusion
	   (setq sp (vlax-ename->vla-object (cdr (assoc 330 (entget (ssname s 0))))))
	   ;; Foreach polyline
	   (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	     ;; Change elevation to 88.88
	     (vla-put-elevation (setq o (vlax-ename->vla-object e)) 88.88)
	     ;; Try to extrude 88.88 with 0 taper
	     (if (setq ex (_extrude sp o 88.88 0.))
	       ;; Put extrusion on same layer as object selected and delete polyline
	       (progn (vla-put-layer ex (cdr (assoc 8 (entget e)))) (entdel e))
	     )
	   )
    )
  )
  (princ)
)(vl-load-com)
0 Likes

Anonymous
Not applicable

Hi,

 

Thanks to helping me. Here it's the file.

 

Is it possible to get the parameter value of base_level or height for the extrusion?

 

 

Thanks!

 

 

0 Likes

Anonymous
Not applicable

this work very well! 

 

Is it possible to get the value of a polyline in that lisp?

 

 

Thank you!

0 Likes

ronjonp
Advisor
Advisor

@Anonymous wrote:

this work very well! 

 

Is it possible to get the value of a polyline in that lisp?

 

 

Thank you!


What do you mean 'get the value of a polyline'?

0 Likes

Anonymous
Not applicable

sorry, I mean get these values : base_lvl and height.

I try to find some ways to do it but I found nothing..

0 Likes

ronjonp
Advisor
Advisor

Maybe this?

(defun c:foo (/ _extrude ex h l o s sp)
  ;; RJP Ā» 2020-03-10
  (defun _extrude (sp o h tp / e r)
    (and (= 'list (type (setq e (vl-catch-all-apply 'vlax-invoke (list sp 'addregion (list o))))))
	 (setq r (vla-addextrudedsolid sp (car e) h tp))
	 (vl-catch-all-apply 'vla-delete (list e))
    )
    r
  )
  ;; Filter lwpolylines on unlocked layers and at zero elevation and are closed
  (if (and (setq l (getreal "\nEnter level: "))
	   (setq h (getdist "\nEnter extrusion height: "))
	   (setq s (ssget "_:L" '((0 . "lwpolyline") (38 . 0.) (-4 . "&=") (70 . 1))))
      )
    (progn ;; Get current space for extrusion
	   (setq sp (vlax-ename->vla-object (cdr (assoc 330 (entget (ssname s 0))))))
	   ;; Foreach polyline
	   (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	     ;; Change elevation to level
	     (vla-put-elevation (setq o (vlax-ename->vla-object e)) l)
	     ;; Try to extrude h with 0 taper
	     (if (setq ex (_extrude sp o h 0.))
	       ;; Put extrusion on same layer as object selected and delete polyline
	       (progn (vla-put-layer ex (cdr (assoc 8 (entget e)))) (entdel e))
	     )
	   )
    )
  )
  (princ)
)
(vl-load-com)
0 Likes

Anonymous
Not applicable

It's a good solution but is it possible to automaticly get the value of the level and of the height directly from the polyline?

All polylines have these parameters.

0 Likes

ronjonp
Advisor
Advisor

Are you using a vertical product ? ( Civil3D etc. ) I don't have access to a height property just the elevation which is 0 for all in your example.

 

Also noticed some xdata on these polylines.

(-3 ("AcMap_E615D161-C9D7-11d3-839F-0060B0FB6B57" (1071 . 2) (1071 . 63) (1071 . 1)))

 This is lost once extruded.

0 Likes

Anonymous
Not applicable

At the begining it's a Shape. I just keep these extra data from the shape.

I dont really need one it's extruded, but I need to know to extrude it. You can have access to these information with a lisp?

0 Likes

ronjonp
Advisor
Advisor

@Anonymous wrote:

At the begining it's a Shape. I just keep these extra data from the shape.

I dont really need one it's extruded, but I need to know to extrude it. You can have access to these information with a lisp?


I don't have access to that information. Post a drawing of before and after .. I'm at a loss as to what you're trying to do.

0 Likes

Sea-Haven
Mentor
Mentor

It may be data from Esri etc a SHP file, so use the OD object data methods to get the elevation of the pline.

 

If you have problems let me know as you may need MAP.

0 Likes

Anonymous
Not applicable

Here it's an example of the start and the end of what I want to do. Manually it's a bit long, so it's why i want to do a lisp for that. Maybe it's not possible with a lisp?

I import a SHP file with Civil 3D and MapImport.

0 Likes

devitg
Advisor
Advisor

As far as I know, plain ACAD, do not give any data to set the extrude height .

 

 

You said that doing it by "hand" it is a bit long .

From where do you get the height to do it one by one. ?

And , if possible, tell us what ACAD version do you use, seem to be it a vertical , like map or civil. 

 

 

 

 

 

 

 

0 Likes

Sea-Haven
Mentor
Mentor
Here is what i found on a random pick.
 

 

(setq ent (car (entsel "\n Select Polyline : ")))
Command: (setq tbl (nth 0 (ade_odgettables ent)))
"Building_STC_11N"
Command: (setq fields (ade_odtabledefn tbl))
(("Tablename" . "Building_STC_11N") ("TableDesc" . "") ("Columns" (("ColName" . "FeatId") ("ColDesc" . "") ("ColType" . "Integer") ("DefaultVal" . 0)) (("ColName" . "osm_id") ("ColDesc" . "") ("ColType" . "Character") ("DefaultVal" . "")) (("ColName" . "ele") ("ColDesc" . "") ("ColType" . "Character") ("DefaultVal" . "")) (("ColName" . "height") ("ColDesc" . "") ("ColType" . "Character") ("DefaultVal" . "")) (("ColName" . "base_lvl") ("ColDesc" . "") ("ColType" . "Real") ("DefaultVal" . 0.0))))

then
(ade_odgetfield ent tbl "osm_id" 0)
(ade_odgetfield ent tbl "ele" 0)
(ade_odgetfield ent tbl "base_lvl" 0)

 

0 Likes

Sea-Haven
Mentor
Mentor
Accepted solution

Found a few minutes, needs "does it have od data check"

 

 

 

(defun c:test ( / ss ent tbl elev ht)
(setq ss (ssget (list (cons 0 "LWPOLYLINE"))))
(repeat (setq x (sslength ss))
(setq ent (ssname ss (setq x (- x 1))))
(setq tbl (nth 0 (ade_odgettables ent)))
(setq elev (ade_odgetfield ent tbl "base_lvl" 0))
(setq ht (ade_odgetfield ent tbl "height" 0))
(command "move" ent "" "0.0,0.0,0.0" (list 0.0 0.0 elev))
(command "extrude" ent "" ht)
)
(princ)
)

 

 

devitg
Advisor
Advisor

Where ADE_ODGETTABLES are? 

 

I got it . it is  map FEATURE 

 

It seem not to be at Plain ACAD 

0 Likes

Sea-Haven
Mentor
Mentor

I have civ3d, Properties should show the OD values at bottom. Else will be a proxy object, not sure what "Proxy enable" add on will do.

 

Briscad error : no function definition <ADE_ODGETTABLES> ; expected FUNCTION at [eval]

0 Likes