Modifying Lisp Works in autocad but Not Civil 3D

Modifying Lisp Works in autocad but Not Civil 3D

My_Civil_3D
Advocate Advocate
363 Views
3 Replies
Message 1 of 4

Modifying Lisp Works in autocad but Not Civil 3D

My_Civil_3D
Advocate
Advocate

i Have a weird issue not sure if it has to do with my code:

 

When i run this Lisp in autocad it modifies my hatch like it suppose to but when i run this in civil 3D it doesnt modify it. Civil 3D is based on the Autocad as the Base application and normally everything that works in Autocad works in civil 3D. Here is my Code:

(defun Hatch_Ansi31_Reversed (/ ss obj entdata newentdata radianAngle)
  ; Hatch Variables
  (setq LayerName ".HATCHING")
  (setq HatchName "ANSI31")
  (setq HatchScale 0.025)
  (setq HatchAngle 90)
  
  ; Convert angle from degrees to radians
  (setq radianAngle (* HatchAngle (/ pi 180.0)))
  
  ; Hatch Command
  (command "_.-hatch" pause)
  (while (> (getvar 'cmdactive) 0)
    (command pause)
  )
  ; Get Last Hatch
  (setq ss (ssget "_L"))
  ; Modify Hatch
  (if ss
    (progn
      (setq obj (ssname ss 0))
      (setq entdata (entget obj))   
      ; Modify layer
      (setq entdata (subst (cons 8 LayerName) (assoc 8 entdata) entdata))
      ; Modify hatch pattern
      (setq entdata (subst (cons 2 HatchName) (assoc 2 entdata) entdata))
      ; Modify hatch scale
      (setq entdata (subst (cons 41 HatchScale) (assoc 41 entdata) entdata))
      ; Modify hatch angle
      (setq entdata (subst (cons 52 radianAngle) (assoc 52 entdata) entdata))     
      ; Update entity
      (entmod entdata)
      (entupd obj)
    )
  )
  (prompt "\nHatching Complete!")
(princ)
)
Civil 3D Certified Professional
0 Likes
364 Views
3 Replies
Replies (3)
Message 2 of 4

komondormrex
Mentor
Mentor

try this one

(defun Hatch_Ansi31_Reversed (/ LayerName HatchName HatchScale radianAngle hatch_ename hatch_dxf)
	(setq LayerName ".HATCHING")
	(setq HatchName "ANSI31")
	(setq HatchScale 0.025)
	(setq radianAngle (* 90 (/ pi 180)))
	(while (null
		   		(and (setq hatch_ename (car (entsel "\nPick hatch to change: ")))
		   			 (= "HATCH" (cdr (assoc 0 (entget hatch_ename))))
					 (/= 4 (cdr (assoc 70 (entget (tblobjname "layer" (cdr (assoc 8 (entget hatch_ename))))))))
					 (setq hatch_dxf (entget hatch_ename))
		   		)
		   )
	)
	(entmod (foreach group (list (cons 8 LayerName) (cons 2 HatchName) (cons 41 HatchScale) (cons 52 radianAngle))
				(setq hatch_dxf (subst group (assoc (car group) hatch_dxf) hatch_dxf))
			)
	)
)

 

0 Likes
Message 3 of 4

My_Civil_3D
Advocate
Advocate

Same thing still doesn't modify all properties of the hatch

Civil 3D Certified Professional
0 Likes
Message 4 of 4

komondormrex
Mentor
Mentor

which exactly does not? can't however check this in c3d.

0 Likes