Author Topic: How to solve the problem that region object cannot be extrude  (Read 989 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 286
hi frends
i need some help
I made some extrude code modifications

But this code doesn't extrude the region

Can you help me make this possible ?

Code: [Select]
(defun c:c4 ( /  ss)


   (vl-load-com)
    (or *acdoc*
      (setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object)))
  )
 
 
   

   
(if (setq ss (ssget ))
 
 
 
 



(progn


         (if ( not de-hi ) (setq de-hi  200 ) )
(setq detemp-hi (getreal (strcat "\n  height   <"  (rtos de-hi)  ">:")))
(if detemp-hi (setq de-hi detemp-hi))



(vlax-for obj (setq ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object))))

           
     


(setq reg (vl-catch-all-apply
'vlax-invoke
(list sp 'addRegion(list obj)))
)



(or (vl-catch-all-error-p reg)
(and
  (vla-addExtrudedSolid  sp  (car reg) de-hi 0.0   )
  (vla-delete (car reg))
)
)
)




 
)
 
 
)
 
 
  )
« Last Edit: June 25, 2022, 11:36:44 PM by dussla »

ronjonp

  • Needs a day job
  • Posts: 7526
Re: How to solve the problem that region object cannot be extrude
« Reply #1 on: June 23, 2022, 12:33:59 PM »
Try this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:c4 (/ de-hi detemp-hi reg sp ss)
  2.   (if (setq ss (ssget))
  3.     (progn
  4.       (if (not de-hi)
  5.         (setq de-hi 200)
  6.       )
  7.       (setq detemp-hi (getreal (strcat "\n  height   <" (rtos de-hi) ">:")))
  8.       (if detemp-hi
  9.         (setq de-hi detemp-hi)
  10.       )
  11.       (vlax-for obj (setq
  12.                     )
  13.         ;; If we already have a region extrude it
  14.         (if (= "AcDbRegion" (vla-get-objectname obj))
  15.           (vla-addextrudedsolid sp obj de-hi 0.0)
  16.           ;; Else try to create a region and extrude it
  17.           (or (vl-catch-all-error-p
  18.                 (setq reg (vl-catch-all-apply 'vlax-invoke (list sp 'addregion (list obj))))
  19.               )
  20.               (and (vla-addextrudedsolid sp (car reg) de-hi 0.0) (vla-delete (car reg)))
  21.           )
  22.         )
  23.       )
  24.     )
  25.   )
  26.   (princ)
  27. )

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

dussla

  • Bull Frog
  • Posts: 286
Re: How to solve the problem that region object cannot be extrude
« Reply #2 on: June 23, 2022, 01:58:44 PM »
really really  really really   thank you .
I'm sorry, but can I ask you one more thing?
I added the following code.
However, the harm does not become an extrud.
pls Can you help?

"command  extrude" is possible
Code: [Select]

(defun h2r  ( ss num / el   i h reg sp )
(vl-load-com)
 
(or *acdoc*
      (setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object)))
  )
 

  (setq el (entlast))
  (setq s (ssadd))
 
  (repeat (setq i (sslength ss))
    (setq h (ssname ss (setq i (1- i))))
(setq la (cdr (assoc 8 (entget h))))
  (setvar "clayer" la)
    (command "_.-HATCHEDIT" h "_B" "_R" "_N")
    (command "_.-HATCHEDIT" h "_DI")
    (if (not (eq el (entlast))) (ssadd (entlast) s))
  )
   
     (command "_erase" ss "")
 
  (vlax-for obj (setq
  s (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))
)


;; If we already have a region extrude it
(if (= "AcDbRegion" (vla-get-objectname obj))
  (vla-addextrudedsolid sp obj num 0.0)
  ;; Else try to create a region and extrude it
  (or (vl-catch-all-error-p
(setq reg (vl-catch-all-apply 'vlax-invoke (list sp 'addregion (list obj))))
  )
  (and (vla-addextrudedsolid sp (car reg) num 0.0) (vla-delete (car reg)))
  )
)
  )
   
 
(princ)
   )


( defun c:hs2 ( / )

(setq ss (ssget "_:L" '((0 . "HATCH"))))
( h2r  ss 100 )


)
« Last Edit: June 25, 2022, 11:36:03 PM by dussla »

ScottMC

  • Newt
  • Posts: 191
Re: How to solve the problem that region object cannot be extrude
« Reply #3 on: June 25, 2022, 08:12:45 PM »
 [a2k] won't run w/o adding:

Code: [Select]
(defun c:c4 (/ de-hi detemp-hi reg sp ss)
  (vl-load-com)

      (setq acadObj (vlax-get-acad-object))             ;; <-- inserted lines..
    (setq doc (vla-get-ActiveDocument acadObj))   ;; <--  got from:
    (setq sp (vla-get-ModelSpace doc))                 ;; <--

;;; https://help.autodesk.com/view/OARX/2020/DEU/?guid=GUID-B9DEA4C5-EDAA-4CC6-93B0-394D5991A0E6
  (or *acdoc* (setq *acdoc* (vla-get-activedocument (vlax-get-acad-object))))
....
....
(princ)
)

« Last Edit: June 26, 2022, 09:01:08 PM by ScottMC »

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: How to solve the problem that region object cannot be extrude
« Reply #4 on: June 25, 2022, 08:51:49 PM »
Clock on # this is for code section.
A man who never made a mistake never made anything

dussla

  • Bull Frog
  • Posts: 286
Re: How to solve the problem that region object cannot be extrude
« Reply #5 on: June 25, 2022, 11:34:34 PM »
Wow  wow really thank you~

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: How to solve the problem that region object cannot be extrude
« Reply #6 on: June 26, 2022, 01:00:59 AM »
@dussla,
please review Ron's code and if you will ask yourself for entity type you are selecting is it regionable or not...
After (vlax-for obj ...
consider putting
  (if (and (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-curve-getendpoint) (list obj)))) (vlax-curve-isclosed obj))
    ...
...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

dussla

  • Bull Frog
  • Posts: 286
Re: How to solve the problem that region object cannot be extrude
« Reply #7 on: June 26, 2022, 02:45:31 AM »
thank you  thank you for good advice

ribarm

  • Gator
  • Posts: 3225
  • Marko Ribar, architect
Re: How to solve the problem that region object cannot be extrude
« Reply #8 on: June 27, 2022, 11:02:03 PM »

thank you  thank you for good advice
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube