Jump to content

get length of pline, arc or spline from selected


Recommended Posts

Posted

I've created a copy on to path tool but I'm having issues when it comes to getting the length of a spline or and arc.

 

how could I implement it so the user could selected either a pline, arc or spline and it will get the length of the line?

 

as well is it possible to implement it so if a user has selected a pline, arc or spline already it will skip past the 'select line' part?

 

current code:

(defun c:tester (/ pline len MSpace dist)
  (defun upDateImage(sldName key)
    (setq width (dimx_tile key))
    (setq height (dimy_tile key))
    (start_image key)
    (fill_image 0 0 width height 0)
    (slide_image 0 0 width height sldName)
    (end_image)
  )
    
  (setq dcl_id (load_dialog "C:\\BricsCAD Scripts\\MACROS\\DIALOGS\\CONELINE.dcl"))
  (if (not (new_dialog "CONELINE" dcl_id))
    (exit)
  )
  
  
  (upDateImage "C:\\BricsCAD Scripts\\MACROS\\SLIDES\\CONE_LINE.sld" "coningimage")
  (if (= lastSel Nil) (set_tile "c10" "1") (set_tile lastSel "1"))
  (action_tile "c10"  "(setq lastSel \"c10\")(setq spacing 1)")
  (action_tile "c15"  "(setq lastSel \"c15\")(setq spacing 1.5)")
  (action_tile "c20"  "(setq lastSel \"c20\")(setq spacing 2)")
  (action_tile "c30"  "(setq lastSel \"c30\")(setq spacing 3)")
  (action_tile "c40"  "(setq lastSel \"c40\")(setq spacing 4)")
  (action_tile "c50"  "(setq lastSel \"c50\")(setq spacing 5)")
  (action_tile "c90"  "(setq lastSel \"c90\")(setq spacing 9)")
  (action_tile "c100"  "(setq lastSel \"c100\")(setq spacing 10)")
  (action_tile "c180"  "(setq lastSel \"c180\")(setq spacing 18)")
  (action_tile "custom"  "(setq lastSel \"c10\"(setq spacing (atof $VALUE))")
  (start_dialog)
  (unload_dialog dcl_id)
    
    
  (setq pline (vlax-ename->vla-object (car (entsel "\nSelect polyline: ")))
        len (vla-get-length pline)
        ;len (vla-get-arclength pline) - arc
        ;len (vlax-curve-getdistatparam pline (vlax-curve-getendparam pline)) - spline
        MSpace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
        dist spacing
  )
  
  ;Insert "first" block from folder
  (vla-insertblock 
    MSpace
    (vlax-curve-getpointatdist pline dist)
    "C:\\BricsCAD Scripts\\MACROS\\DWG\\CONE.dwg"
    1
    1
    1
    0
  )
  (setq dist (+ dist spacing))
  
  
  (repeat (- (fix (/ len spacing)) 1) ;Insert block from libary
    (vla-insertblock
      MSpace
      (vlax-curve-getpointatdist pline dist)
      "CONE" 
      1
      1
      1
      0
    )
    (setq dist (+ dist spacing))
  )
  (princ)
)

 

Posted (edited)
  (setq pline (vlax-ename->vla-object (car (entsel "\nSelect polyline: ")))
        len (vla-get-length pline)
        ;len (vla-get-arclength pline) - arc
        ;len (vlax-curve-getdistatparam pline (vlax-curve-getendparam pline)) - spline
        MSpace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
        dist spacing
  )
  
 

(setq ent (car (entsel "\nSelect polyline: ")))
      len (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) ;works on all three
      MSpace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
      dist spacing
)
Edited by mhupp
Posted
14 minutes ago, mhupp said:
  (setq pline (vlax-ename->vla-object (car (entsel "\nSelect polyline: ")))
        len (vla-get-length pline)
        ;len (vla-get-arclength pline) - arc
        ;len (vlax-curve-getdistatparam pline (vlax-curve-getendparam pline)) - spline
        MSpace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
        dist spacing
  )
  
 

(setq ent (car (entsel "\nSelect polyline: ")))
      len (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent)) ;works on all three
      MSpace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
      dist spacing
)

 

 

perfect cheers

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...