Jump to content

Insert item along a curve/polyline angle


Charpzy

Recommended Posts

i've got a script which will align item along a line at  specific distance point, but i'm struggling to find/ understand how to then insert them onto the line following the rotation of the arc, polyline or spline

 

the moment im inserting them to the angle 0

 

      (setq drv (start_dialog))
      (cond
        ((= drv 1)
         (progn
          (while (= (setq ent (car (entsel "\nSelect Object Curve (Arc, Circle, Line, Polyline or Spline) "))) Nil)
                  (princ "\nNo Object Selected, Try Again"))
          (setq len (vlax-curve-getdistatparam ent (vlax-curve-getendparam ent))
                actSpace (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))
                dist spacing
          )
          (vla-insertblock
            actSpace
            (vlax-curve-getpointatdist ent dist)
            (strcat "C:\\BricsCAD Scripts\\MACROS\\DWG\\" fileName ".dwg")
            1.0 1.0 1.0 0.0)
          (setq dist (+ dist spacing))
          (repeat (- (fix (/ len spacing)) 1)
            (vla-insertblock
              actSpace
              (vlax-curve-getpointatdist ent dist)
              block
              1.0 1.0 1.0 0.0)
            (setq dist (+ dist spacing)))
         );progn
        )
        (t (princ))
      );cond
    );progn
  );if
);defun

 

Link to comment
Share on other sites

(setq param (vlax-curve-getParamAtDist ent dist))
(setq ang (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv ent param)

 

You can find the angle tangent to the line using the vlax-curve-getFirstDeriv function.

Hope this helps.

  • Like 1
Link to comment
Share on other sites

That worked perfect thanks

26 minutes ago, dexus said:
(setq param (vlax-curve-getParamAtDist ent dist))
(setq ang (angle '(0.0 0.0 0.0) (vlax-curve-getFirstDeriv ent param)

 

You can find the angle tangent to the line using the vlax-curve-getFirstDeriv function.

Hope this helps.

 

Link to comment
Share on other sites

I'm having an issue trying to get the last selected, to remember the previously selected item & spacing.

 

it keeps reading meterSel as a nil value and defaulting to false in the if statement

 

  (if (not (setq fn (findfile "MACROS\\DIALOGS\\CONELINE.dcl")))
    (alert "Dialog CONELINE.dcl not found")
    (progn
      (setq dlg_id (load_dialog fn))
      (new_dialog "CONELINE" dlg_id)
      (updateImage "CONE_LINE")
      (if (= typeSel Nil) (set_tile "t1" "1") (set_tile typeSel "1"))
      (if (= meterSel Nil)
        (progn
          (set_tile "c20" "1")
          (mode_tile "parking_spacing" 1)
          (setq block "BOLLARD"
                spacing 2
                FileName "CONEORBOLLARD")
        );progn
        (set_tile meterSel "1")
      );if
      
      ; Type Selection
      (action_tile "t1" "(updateImage \"CONE_LINE\") (setq typeSel \"t1\") (mode_tile \"cone_spacing\" 0) (mode_tile \"parking_spacing\" 1) (setq block \"BOLLARD\") (setq FileName \"CONEORBOLLARD\")")
      (action_tile "t2" "(updateImage \"PARKING_CONES\") (setq typeSel \"t2\") (mode_tile \"cone_spacing\" 1) (mode_tile \"parking_spacing\" 0) (setq block \"PARKINGBOLLARD\") (setq FileName \"PARKINGCONE\")")
  
      (action_tile "c10" "(setq meterSel \"c10\") (setq spacing 1)")
      (action_tile "c15" "(setq meterSel \"c15\") (setq spacing 1.5)")
      (action_tile "c20" "(setq meterSel \"c20\") (setq spacing 2)")
      (action_tile "c30" "(setq meterSel \"c30\") (setq spacing 3)")
      (action_tile "c40" "(setq meterSel \"c40\") (setq spacing 4)")
      (action_tile "c50" "(setq meterSel \"c50\") (setq spacing 5)")
      (action_tile "c90" "(setq meterSel \"c90\") (setq spacing 9)")
      (action_tile "c100" "(setq meterSel \"c100\") (setq spacing 10)")
      (action_tile "c180" "(setq meterSel \"c180\") (setq spacing 18)")
      (action_tile "cCustom" "(setq meterSel \"cCustom\") (setq spacing (atof $VALUE))")

      (action_tile "p10" "(setq meterSel \"p10\") (setq spacing 1)")
      (action_tile "p15" "(setq meterSel \"p15\") (setq spacing 1.5)")
      (action_tile "p20" "(setq meterSel \"p20\") (setq spacing 2)")
      (action_tile "p30" "(setq meterSel \"p30\") (setq spacing 3)")
      (action_tile "p40" "(setq meterSel \"p40\") (setq spacing 4)")
      (action_tile "p50" "(setq meterSel \"p50\") (setq spacing 5)")
      (action_tile "p90" "(setq meterSel \"p90\") (setq spacing 9)")
      (action_tile "p100" "(setq meterSel \"p100\") (setq spacing 10)")
      (action_tile "p180" "(setq meterSel \"p180\") (setq spacing 18)")
      (action_tile "pCustom" "(setq meterSel \"pCustom\") (setq spacing (atof $VALUE))")

 

Link to comment
Share on other sites

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