Author Topic: Is there a way with Visual Lisp to change the AEC Wall Z coordinate value  (Read 2416 times)

0 Members and 1 Guest are viewing this topic.

Vince

  • Newt
  • Posts: 55
Is there a way with Visual Lisp to change the AEC Wall Z coordinate value (Elevation on Property Window)......??



Thank you,
Vince

Vince

  • Newt
  • Posts: 55
Code: [Select]
We have AutoCAD drawings where the AEC Walls are at different Z coordinate values (10'-0", 22'-0", -11'-0", etc.) We need to get all of the walls down to the 0'-0" Z coordinate.  I know this can be done manually by selecting all the walls and then open the "Properties" window and set the Elevation to 0'-0".  However, I am looking for a way to do this via a lisp or Vlisp routine.  I tried to write some code to do this but it is not working.......here is the example:


Code: [Select]

;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(Defun C:WLto0 (/)
 
  (SETVAR "CMDECHO" 0)

  (Setq NewEl "0")

;;;;;;
;;;;;;UPDATE  WALLS
;;;;;;
  (vl-load-com)

;;;;;;
;;;;;;
   (setq ent_list (ssget "_X" (list (cons 0 "aec_wall")    )))
   (if (/= ent_list " ")
      (progn
         (command "undo" "mark")
         (setq ent_list_length (sslength ent_list))
         (setq index 0)
         (while (< index ent_list_length)
   
            (setq ent_vbaobj (vlax-ename->vla-object(ssname ent_list index)))
                   
            (vlax-put-property ent_vbaobj "Elevation" NewEl)

            (setq  index (1+ index))
     
      )
    )
      (prompt "...No 3D Walls Selected...")
  )


  (Prompt "\n...")
  (Prompt "\n...WALLS  Have Been Moved to Elevation  =  0\'-0\"...")
  (princ)
)


Can anyone show examples on the correct way to accomplish this....??



Thank you,
Vince

ronjonp

  • Needs a day job
  • Posts: 7527
Not having an AEC version of CAD this is blindly coded. Maybe someone in the same field can help you out better.
Code: [Select]
(defun c:wlto0 (/ ent_list ent_list_length ent_vbaobj index)
  (setvar "CMDECHO" 0)
  (vl-load-com)
  (if (setq ent_list (ssget "_X" (list (cons 0 "aec_wall"))))
    (progn (command "undo" "mark")
      (setq ent_list_length (sslength ent_list))
      (setq index 0)
      (while (< index ent_list_length)
        (setq ent_vbaobj (vlax-ename->vla-object (ssname ent_list index)))
        ;; Assuming that the 'aec_wall' has an elevation property
        (vlax-put-property ent_vbaobj 'elevation 0.0)
        (setq index (1+ index))
      )
    )
    (prompt "...No 3D Walls Selected...")
  )
  (prompt "\n...")
  (prompt "\n...WALLS  Have Been Moved to Elevation  =  0\'-0\"...")
  (princ)
)
« Last Edit: January 15, 2014, 12:41:24 PM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Vince

  • Newt
  • Posts: 55
Thank you but for your response but it did not work.....!



Vince

ronjonp

  • Needs a day job
  • Posts: 7527
Thank you but for your response but it did not work.....!

Vince


I kinda figured it wouldn't .. but you have a base to troubleshoot. :P

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
You need to adjust the Z value of the Startpoint and Endpoint properties, there is no Elevation property of the aec_wall object. Nevermind, those aren't editable properties...still looking.

OK, they are editable, they just don't like to be set the shortcut way....(using vlax-put with a list, must use vlax-put-property with a 3dpoint)

Code - Auto/Visual Lisp: [Select]
  1. (setq wall (vlax-ename->vla-object (car (entsel))))
  2. (setq startpt (vlax-get wall 'startpoint)
  3.       endpt (vlax-get wall 'endpoint)
  4.       location (vlax-get wall 'location)
  5.       )
  6. (setq newstart (list (car startpt) (cadr startpt) 0))
  7. (setq newend (list (car endpt) (cadr endpt) 0))
  8.  
  9. (vlax-put-property wall 'startpoint (vlax-3d-point newstart))
  10. (vlax-put-property wall 'endpoint (vlax-3d-point newend))
  11.  
« Last Edit: January 15, 2014, 05:30:12 PM by Jeff_M »

Vince

  • Newt
  • Posts: 55
Hi Jeff,

Thank you for your expert response and code.......it worked perfectly. All of the walls were moved to the zero (0) Elevation....!!

If I can impose upon you I do have another question.  We have drawings where all elements are at various Z coordinate elevations and I have been working on a routine to correct the problem and place everything at the zero (0) Z coordinate utilizing a lisp routine.  I do not want to use the "flatten" command because there are many Dynamic Blocks on these drawings that would be affected by that routine.

I am now trying to move the end points of all the lines on these drawings to the zero (0) Z coordinate and I am having some difficulty with this.  Can you provide an example of how I can accomplish this....??   Your assistance would be appreciated....!!



Regards,
Vince

Jeff_M

  • King Gator
  • Posts: 4094
  • C3D user & customizer
Assuming you have your line entity in a variable named linent, you can use either base lisp list manipulation or the ActiveX methods. There are lots of examples for changing the start and end points of lines here. I'd give links to some but am swamped today at work, even though it's supposed to be a holiday.