Jump to content

Using Arraypath function via scripting, duplicating lines are created in opposite direction of curve path


Recommended Posts

Posted (edited)
(defun c:AUTOHPA ( / objLayer pathLayer objSS pathSS objToArray pathCurve pathLength )
  (setvar "CMDECHO" 0)

  ;; Define your custom layer names here
  (setq objLayer  "V1")  ; <-- Replace with your object layer name
  (setq pathLayer "P1")    ; <-- Replace with your path layer name
  
   ;; Number of items
  (setq items 10)

  ;; Automatically select everything on the object layer
  (setq objSS (ssget "_X" (list '(0 . "*") (cons 8 objLayer))))
  
  ;; Automatically select the first/only object on the path layer
  (setq pathSS (ssget "_X" (list '(0 . "*") (cons 8 pathLayer))))

  (princ "working01")
  ;; Check if both selections actually found objects
  (if (and objSS pathSS)
    (progn
      ;; Get the first entity name from the path selection set
      (setq pathCurve (ssname pathSS 0))
      
       ;; 3. Calculate the exact length of the path object automatically
      (setq pathLength (vlax-curve-getDistAtParam pathCurve (vlax-curve-getEndParam pathCurve)))
      (princ pathLength)
      
      (princ "working02")
      ;; Execute the array using the full object selection set
      (command "._ARRAYPATH" objSS "" pathCurve "M" "M" "I" items pathLength "" "X")

      (princ "\nArray completed successfully using layers.")

    )
    (princ "\nError: Objects or Path curve not found on the specified layers.")
  )

  (setvar "CMDECHO" 1)
  (princ)
)


 

Edited by SLW210
Added Code Tags!!
Posted

Please use Code Tags when posting code. (use <> in the Editor)

 

Do you have a drawing with a before and after?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...