Author Topic: Educate me please - Extrusion Direction DXF code 210  (Read 9113 times)

0 Members and 1 Guest are viewing this topic.

SMadsen

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #15 on: October 28, 2004, 06:40:52 AM »
Here's another attempt. Not sure what direction you are looking to move the insert but this moves it along the direction vector.
It should do the whole shebang with selection and distance input but no error checking to see if input is valid.

Code: [Select]
(defun C:MOVEINS ()
  ;; get an insert (no error checking!)
  ;; get a displacement distance
  (setq blk (entsel "\nSelect block: ")
        len (getdist "\nDistance to move: ")
  )
  ;; get entity list and extract
  ;; insertion point and direction vector
  (setq blkl (entget (car blk))
        ins  (cdr (assoc 10 blkl))
        dir  (cdr (assoc 210 blkl))
  )
  ;; calculate actual insertion point and
  ;; move it len units along the direction vector
  (setq realins (trans ins dir 1)
        newpt   (mapcar '+ realins (mapcar '(lambda (n) (* n len)) dir))
  )
  ;; transform newpt back to insertion point
  ;; and update block
  (entmod (subst (cons 10 (trans newpt 1 dir))(assoc 10 blkl) blkl))
)

CADaver

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #16 on: October 28, 2004, 08:24:57 AM »
HAPPY HAPPY JOY JOY HAPPY HAPPY JOY JOY

That's it, thanks Stig, works a champ.  Now, I just gotta bend it into the rest of my little function.

Not gonna tell where I screwed up the Lambda function last night.  That's what I get for trying to write code on the back end of a 16hr day.

Thanks for all the help guys.

Oh, yeah, brain damage was minimal, but then it had no choice.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Educate me please - Extrusion Direction DXF code 210
« Reply #17 on: October 28, 2004, 08:30:00 AM »
Stig
your routine moved my test block but not along the long axis.
perhaps I did not create my block correctly, but would it not be
better to pick two points on the block to establish the direction
for the block to be moved? I know that is not what CADaver ask for.
I am just kicking this around so I can understand it.

Thanks
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Educate me please - Extrusion Direction DXF code 210
« Reply #18 on: October 28, 2004, 08:33:17 AM »
OK CADaver jumped in there and it looks like you solved his problem.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

whdjr

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #19 on: October 28, 2004, 08:36:04 AM »
Just another thought:
I could see this very useful in this routine that I was writing.  Could it be modified to work with polyline points or is this strictly for blocks?

SMadsen

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #20 on: October 28, 2004, 08:47:46 AM »
Will, this was strictly for blocks .. given that it transforms insertion points .. but you can use TRANS to transform any points for whichever kind of entity. Just keep in mind that lightweight plines have the Z value placed in an elevation and not within the vertices.

CAB, I took a stab at moving the block along the direction vector, not knowing if this was the direction CADaver wanted because it wasn't specified how the block was defined. You could define whichever direction to move it by rotating the direction vector accordingly

CADaver

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #21 on: October 28, 2004, 08:51:34 AM »
Quote from: CAB
Stig
your routine moved my test block but not along the long axis.
perhaps I did not create my block correctly,
Thanks


The block I'm using is a "column" with X and Y scales of 1 and a Z scale of the "column" height, insertion point at the bottom.  When used as a "brace" we just rotate it away from vertical, then "spin" it where it needs to point.

I have a routine that builds it originally along a previously drawn centerline, but you guys know just how quick something can change.  What we've been doing when stuff changes is just delete the old and build new, I was lookin' for a way to just modify what's there.  Reaching in and changing the Z scale with entmod was pretty easy, but moving the "brace" along it's Z axis made me stutter.

I think I may have it now, if I really understand what I think I see happening in Stig's routine.

Again, thanks guys.