Extrude using object layer

Extrude using object layer

ADSK2007
Enthusiast Enthusiast
2,190 Views
7 Replies
Message 1 of 8

Extrude using object layer

ADSK2007
Enthusiast
Enthusiast

Hello all

 

I found this really useful lisp routine by "Geobuilder" which allows for extruding 2D entities into 3D using the object layer instead of current layer. The only issue is that it pause for a variable. Is there a way to modify the routine so that the user can use the mouse click instead of typing a number? Below is the routine

I read in another thread by using dist function I will have a choice between entering a number or using the mouse but I don't know lisp to modify the code.

 

Greately appreciate any help I can get with this

Regards

 

F

 

(defun c:geo_extrude (/ nabor dlina i oldcolor sloy ima cvet 3Dob c b)
  (setq	nabor	 (SSGET ":L" '((0 . "LWpolyline,circle")))
	dlina	 (SSLENGTH nabor)
	i	 -1
	oldcolor (getvar "CECOLOR")
	b (getreal "Height of extruding")

  )
  (setvar "CECOLOR" "1");appoint any colour, that only not "BYLAYER"
  (REPEAT dlina				;(REPEAT
    (SETQ
      sloy (ASSOC 8
		  (SETQ ima (ENTGET (SSNAME nabor (SETQ i (1+ i)))))
	   )
      cvet (if (ASSOC 62 ima)
	     (ASSOC 62 ima)
	     '(62 . 256)
	   )

    )
    (if	(= (cdr (ASSOC 0 ima)) "CIRCLE")
      (setq c 0)
      (extrude-y-n ima)
    )
    (if	(= c 0)				;(if
      (progn				;(progn
	(VL-CMDF "_extrude" (CDR (ASSOC -1 ima)) "" b)
	(SETQ 3Dob (ENTGET (entlast))
	      3Dob (SUBST sloy (ASSOC 8 3Dob) 3Dob)
	      3Dob (SUBST cvet (ASSOC 62 3Dob) 3Dob)
	)
	(entmod 3Dob)
      )					;)progn
    )					;)if
  )					;)REPEAT
  (setvar "CECOLOR" oldcolor)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun extrude-y-n (ima / spisversh dlina a b)
  (setq	spisversh
		  (mapcar
		    'cdr
		    (vl-remove-if-not '(lambda (x) (= (car x) 10)) ima)
		  )
	dlina	  (1- (length spisversh))
	a	  -1
	c	  0
  )
  (if (or (= (cdr (assoc 70 ima)) 1)	;(if1
	  (equal (nth 0 spisversh) (nth dlina spisversh))
      )
    (progn				;(progn
      (repeat dlina			;(repeat1
	(setq a	(1+ a)
	      b	-1
	)
	(repeat	dlina			;(repeat2
	  (setq b (1+ b))
	  (if				;(if2
	    (and (> (abs (- a b)) 1)
		 (or (/= a 0) (/= b (1- dlina)))
		 (or (/= b 0) (/= a (1- dlina)))
	    )
	     (if			;(if3
	       (inters (nth a spisversh)
		       (nth (1+ a) spisversh)
		       (nth b spisversh)
		       (nth (1+ b) spisversh)
	       )
		(setq c 1)
	     )				;)if3
	  )				;)if2
	)				;)repeat2
      )					;)repeat1
    )					;)progn
    (setq c 1)
  )					;)if1
)

 

 

0 Likes
Accepted solutions (2)
2,191 Views
7 Replies
Replies (7)
Message 2 of 8

Ranjit_Singh
Advisor
Advisor

try replacing

(getreal "Height of extruding")

with

 

(getdist "Height of extruding")
0 Likes
Message 3 of 8

ADSK2007
Enthusiast
Enthusiast

Hi Ranjit

 

Thank you for the reply. I did try doing that but it gives me errors. I think that is not the only line that needs to be changed. I don't know lips programming to get the code right

 

Regards

 

F

0 Likes
Message 4 of 8

Ranjit_Singh
Advisor
Advisor

What error do you get? Simply changing that one line does this for megeo_extrude.gif

0 Likes
Message 5 of 8

ADSK2007
Enthusiast
Enthusiast

Ok, I changed the code to what you suggested and it seems to work however; when I select the two points with my mouse, the height of extrusion is equal to the distance of first and second point. I need the height to be the "Z distance" between point a and point b

 

Regards

0 Likes
Message 6 of 8

Ranjit_Singh
Advisor
Advisor
Accepted solution

Try to relace that same line with this

(caddr (mapcar '- (getpoint "Select second point for height of extrusion:" (setq pt1 (getpoint "\nSelect first point for height of extrusion: "))) pt1))
0 Likes
Message 7 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

@ADSK2007 wrote:

... when I select the two points with my mouse, the height of extrusion is equal to the distance of first and second point. I need the height to be the "Z distance" between point a and point b ....


That could probably be worked into some custom code, but if you are Osnapping to points that aren't at the same XY location, and you just want the Z difference between them, you can also use point filters.  Pick your 'a', then type .Z [note the preceding period/decimal] and pick your 'b', and when it says it needs the XY part, pick on 'a' again.

Kent Cooper, AIA
0 Likes
Message 8 of 8

ADSK2007
Enthusiast
Enthusiast

I greatly appreciate all your help.

 

Best Regards

 

F

0 Likes