Charpzy Posted October 31, 2022 Posted October 31, 2022 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) ) Quote
mhupp Posted October 31, 2022 Posted October 31, 2022 (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 October 31, 2022 by mhupp Quote
Charpzy Posted October 31, 2022 Author Posted October 31, 2022 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 Quote
Recommended Posts
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.