Hi all,
I need a function that will allow me to do a "divide" with blocks but I need the single attribute to remain intact. Does anyone here know of anything like that?
I need the blocks to align with object and keep the attribute. I did get it to work with constants but the function that I need to run next failed because of the constant. My variable is preset and locked.
Thank you.
Solved! Go to Solution.
Solved by mid-awe. Go to Solution.
Here is a quick example, try to adopt them to your nrrds,
change block name, scale etc:
;;-----------------------------------------------------------------------;; (defun c:DVB (/ acsp div dpar en epar gettangent leg obj pt pure spar step) (vl-load-com) ;; written by VovKa (defun gettangent (curve pt) (setq param (vlax-curve-getparamatpoint curve pt) ang ((lambda (deriv) (if (zerop (cadr deriv)) (/ pi 2) (atan (apply '/ deriv)) ) ) (cdr (reverse (vlax-curve-getfirstderiv curve param) ) ) ) ) ang ) ;; main part ;; (setq acsp (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object))))) (if (and (setq en (entsel "\nSelect pline: ")) (setq step (getreal "\nStep distance: "))) (progn (setq obj (vlax-ename->vla-object (car en)) leg (vlax-curve-getDistAtParam obj( vlax-curve-getEndParam obj)) div (fix (/ leg step)) pure (* div step)) (setq spar (vlax-curve-getstartparam obj) dpar (- (vlax-curve-getparamatdist obj step) spar) epar (vlax-curve-getendparam obj)) (while (< spar epar) (setq pt (vlax-curve-getclosestpointto obj (vlax-curve-getpointatparam obj spar))) (vl-catch-all-apply 'vla-insertblock (list acsp (vlax-3d-point pt) "MyBlockName" 1 1 1 (gettangent obj pt))) (setq spar (+ spar dpar))))) (princ) ) ;;-----------------------------------------------------------------------;;
Hi,
>> I need a function that will allow me to do a "divide" with blocks but I need the single attribute to remain intact
Just to make sure, what version of AutoCAD do you have? Because since AutoCAD 2012 you have the associative array also for objects along paths, see command _ARRAYPATH (>>>details<<<).
- alfred -
Thank you for that. I'm on 2013 but all the other machines that I must support are 2012. I did not know ARRAYPATH, That's worth a try.
The thing is my block is set off of 0,0 so that is stands away from the polyline, but in the center of the block is a single attribute that I need to rotate to 0deg. Once the attribute was dropped I could not re-add it but also when I set the attribute to constant it would appear but was not able to be rotated. I'll give ARRAYPATH a try first thing in the morning. Thank you again.
Yeah I can, but I don't want the constant; it was the only way I was able to keep the attribute in the function, but it was not able to be aligned to 0 so it's no good.
Arraypath is interesting and I'll keep it in mind for future projects, but in this case it does not work. A few reasons. I will need the path divided by specific numbers and array path works more like the measure command. I could get the length and user input, do the math, and then automate the command, but it still wouldn't work because of other step I need. I need the block to align. The arraypath for whatever reason is placing the block far outside and not keeping the insert point on the path like divide does.
It was worth a try, I always prefer built-in functions first. Thank you.
Thank you, very nice function, but also fails to do as I need. I'll look more deeply into it since it seems to work nicely for what it does, but it forces the block to stand upright, which unfortunately will not always be the case for my needs, that is why I rotate the attribute instead of the entire block.
Thank you, there is some nice vl use in that function and I'm sure I'll learn alot studying it.
Ok, I worked out a solution. It's far from ideal but it works.
I created a custom TIC for this application and after the "divide" command runs, I use "acet-block-replace" to swap out the TIC for my block which then requires "attsync" before my attributes are visible. Then I can run my AttAlign function to rotate the attributes in a repeat loop until they are all set the way I need them to be.
Anyway, thank you all for your help. It's good to see this forum still banding together.