Jump to content

Recommended Posts

Posted (edited)

I figured one more thing - if 3dsolid is too small it may hang as also if unfolded face isn't exactly rectangle... So here is mine version of hatch by curved path explained process with small half ellipse extruded along spline path but shape positioned perpendicular to path (used vlax-curve-getfirstderiv spline endparam)... And when finished with UVmapping flattened splines with this code :

 

(defun c:splf nil (c:splineflatten))
(defun c:splineflatten ( / ss spl splA coords coordsn fcoords fcoordsn ptx pty elev pt coordsnvar fcoordsnvar )
 (vl-load-com)
 (prompt "\nSelect SPLINE objects")
 (while (not ss)
   (setq ss (ssget "_:L" '((0 . "SPLINE"))))
 )
 (setq elev (getreal "\nType elevation for SPLINE(S) <0.0> : "))
 (if (null elev) (setq elev 0.0))
 (repeat (setq n (sslength ss))
   (setq spl (ssname ss (setq n (1- n))))
   (setq splA (vlax-ename->vla-object spl))
   (setq coords (vlax-safearray->list (vlax-variant-value (vla-get-ControlPoints splA))))
   (if (/= (vla-get-NumberOfFitPoints splA) 0)
     (setq fcoords (vlax-safearray->list (vlax-variant-value (vla-get-FitPoints splA))))
   )
   (setq coordsn '())
   (repeat (/ (length coords) 3)
     (setq ptx (car coords))
     (setq pty (cadr coords))
     (setq pt (list ptx pty elev))
     (setq coords (cdddr coords))
     (setq coordsn (append coordsn pt))
   )
   (setq coordsnvar (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length coordsn) 1))) coordsn)))
   (vla-put-ControlPoints splA coordsnvar)
   (if (/= (vla-get-NumberOfFitPoints splA) 0)
     (progn
       (setq fcoordsn '())
       (repeat (/ (length fcoords) 3)
         (setq ptx (car fcoords))
         (setq pty (cadr fcoords))
         (setq pt (list ptx pty elev))
         (setq fcoords (cdddr fcoords))
         (setq fcoordsn (append fcoordsn pt))
       )
       (setq fcoordsnvar (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length fcoordsn) 1))) fcoordsn)))
       (vla-put-FitPoints splA fcoordsnvar)
     )
   )
 )    
(princ)
)
(princ "\nShortcut for c:splineflatten is c:splf")
(princ)

M.R.

hatch-MR.jpg

hatch-mr.dwg

Edited by marko_ribar
code changed and dwg replaced with new one - full flatten to elev 0.0 of splines
  • Replies 31
  • Created
  • Last Reply

Top Posters In This Topic

  • nod684

    13

  • marko_ribar

    10

  • SEANT

    3

  • eldon

    2

Top Posters In This Topic

Posted Images

Posted
I figured one more thing - if 3dsolid is too small it may hang as also if unfolded face isn't exactly rectangle... So here is mine version of hatch by curved path explained process with small half ellipse extruded along spline path but shape positioned perpendicular to path (used vlax-curve-getfirstderiv spline endparam)... And when finished with UVmapping flattened splines with this code :

 

(defun c:splf nil (c:splineflatten) )
(defun c:splineflatten ( / ss spl splA coords coordsn ptx pty elev pt coordsnvar )
 (vl-load-com)
 (prompt "\nSelect SPLINE objects")
 (while (not ss)
   (setq ss (ssget "_:L" '((0 . "SPLINE"))))
 )
 (setq elev (getreal "\nType elevation for SPLINE(S) <0.0> : "))
 (if (null elev) (setq elev 0.0))
 (repeat (setq n (sslength ss))
   (setq spl (ssname ss (setq n (1- n))))
   (setq splA (vlax-ename->vla-object spl))
   (setq coords (vlax-safearray->list (vlax-variant-value (vla-get-ControlPoints splA))))
   (setq coordsn '())
   (repeat (/ (length coords) 3)
     (setq ptx (car coords))
     (setq pty (cadr coords))
     (setq pt (list ptx pty elev))
     (setq coords (cdddr coords))
     (setq coordsn (append coordsn pt))
   )
   (setq coordsnvar (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length coordsn) 1))) coordsn)))
   (vla-put-ControlPoints splA coordsnvar) 
 )    
(princ)
)
(princ "\nShortcut for c:splineflatten is c:splf")
(princ)

M.R.

 

 

Nice one! how did you you do it?

the UV Mapping is not working for me...am using autocad 2010

 

thanks a lot for sharing

Posted

It is only working on A2009 32 bit... You have A2010, this is why...

 

And unfolded curved surface of 3dsolid may not be exact rectangle but canvas always is... Tried once more and it did projection even when shapes aren't perpendicular to path... What is even more interesting is to see Seant's example - Hatch.dwg (2010 file format - working probably on his comp., but haven't shared dlls, and splines aren't so deformed near boundaries as it's with mine example - don't know how if he used the same dlls as he posted)...

 

M.R.

Posted

Code changed in post #21...

 

To fully flatten splines, you also have to influence on fit points with elevation to 0.0...

 

M.R.

 

P.S. Sean has all his splines fully flattened in his example...

Posted

thanks! i will try it again and if successful will use your revised code

 

thanks a lot Marko

Posted

@ M.R.

 

I cannot define the face of the solid...

 


Command:
CPM

Select face of solid:

Remove face(s) to isolate individual face:
Operation aborted!

 

Am using AutoCAD 2010

Posted

Autodesk made some slight adjustments to the .NET API between AutoCAD 2009 and 2010. That adjustment, unfortunately, broke those two routines.

 

 

 

I’m updating everything but can’t say for certain that it will work for 2010 specifically – as I do not have that version to test against. The update targets versions 2012 – 2013.

 

 

 

If everything is finalized, upload your Path geometry. I’ll see what I can do. The routine update is still a “work in progress” but I can get it to work temporarily.

Posted
Autodesk made some slight adjustments to the .NET API between AutoCAD 2009 and 2010. That adjustment, unfortunately, broke those two routines.

 

 

 

I’m updating everything but can’t say for certain that it will work for 2010 specifically – as I do not have that version to test against. The update targets versions 2012 – 2013.

 

 

 

If everything is finalized, upload your Path geometry. I’ll see what I can do. The routine update is still a “work in progress” but I can get it to work temporarily.

 

thanks for the reply Seant...

i am trying to immitate what M.R. has done :) until now no success hehe!

Posted

What I finally did is this :

- check in bios if your CPU has feature virtualization and enable it...

Download Windows6.1-KB958559-x64-RefreshPkg.msu - this is Virtual PC for Windows 7

Download WindowsXPMode_en-us.exe - this is emulator of XP Service pack 3 for Virtual PC for Windows 7

 

Install WindowsXPMode_en-us.exe

Install Windows6.1-KB958559-x64-RefreshPkg.msu

 

Then go to Start->Programs->Virtual PC->WindowsXPMode - start it => new virtual PC XP Desktop will initialize and wait to complete installation...

 

Download Autodesk AutoCAD 2009 32 bit with 32 bit keygen

Unzip archive with AutoCAD and go to Virtual PC XP mode; start windows explorer and copy unzipped folder from Windows 7 drive to XP drive (desktop if you want)...

 

Install AutoCAD 2009 32 bit on XP (use install readme and activate product with keygen)

 

Now you can use Sean's 2 dll files with netload...

 

BTW... If you plan to make elevation views from your model made from 3D solid geometry, you can use SOLPROF command to make elevations, place UCS to be parallel with made elevation geometry that will lie in one plane and use this modified routine to transform Seant's hatch splines from 3dsolids to plane :

;; Project Point onto Plane  -  Lee Mac
;; Projects pt onto the plane defined by its origin and normal

(defun LM:ProjectPointToPlane ( pt org nm )
   (setq pt  (trans pt  0 nm)
         org (trans org 0 nm)
   )
   (trans (list (car pt) (cadr pt) (caddr org)) nm 0)
)

(defun c:splpucs nil (c:splineprojonucs))
(defun c:splineprojonucs ( / or nor ss spl splA coords coordsn fcoords fcoordsn ptx pty ptz pt ptu coordsnvar fcoordsnvar )
 (vl-load-com)
 (prompt "\nSelect SPLINE objects")
 (while (not ss)
   (setq ss (ssget "_:L" '((0 . "SPLINE"))))
 )
 (setq or (trans '(0.0 0.0 0.0) 1 0))
 (setq nor (mapcar '- (trans '(0.0 0.0 1.0) 1 0) (trans '(0.0 0.0 0.0) 1 0)))
 (repeat (setq n (sslength ss))
   (setq spl (ssname ss (setq n (1- n))))
   (setq splA (vlax-ename->vla-object spl))
   (setq coords (vlax-safearray->list (vlax-variant-value (vla-get-ControlPoints splA))))
   (if (/= (vla-get-NumberOfFitPoints splA) 0)
     (setq fcoords (vlax-safearray->list (vlax-variant-value (vla-get-FitPoints splA))))
   )
   (setq coordsn '())
   (repeat (/ (length coords) 3)
     (setq ptx (car coords))
     (setq pty (cadr coords))
     (setq ptz (caddr coords))
     (setq pt (list ptx pty ptz))
     (setq ptu (LM:ProjectPointToPlane pt or nor))
     (setq coords (cdddr coords))
     (setq coordsn (append coordsn ptu))
   )
   (setq coordsnvar (vlax-make-variant (vlax-safearray-fill  (vlax-make-safearray vlax-vbdouble (cons 0 (- (length coordsn) 1)))  coordsn)))
   (vla-put-ControlPoints splA coordsnvar)
   (if (/= (vla-get-NumberOfFitPoints splA) 0)
     (progn
       (setq fcoordsn '())
       (repeat (/ (length fcoords) 3)
         (setq ptx (car fcoords))
         (setq pty (cadr fcoords))
         (setq ptz (caddr fcoords))
         (setq pt (list ptx pty ptz))
         (setq ptu (LM:ProjectPointToPlane pt or nor))
         (setq fcoords (cdddr fcoords))
         (setq fcoordsn (append fcoordsn ptu))
       )
       (setq fcoordsnvar (vlax-make-variant (vlax-safearray-fill  (vlax-make-safearray vlax-vbdouble (cons 0 (- (length fcoordsn) 1)))  fcoordsn)))
       (vla-put-FitPoints splA fcoordsnvar)
     )
   )
 )    
(princ)
)
(princ "\nShortcut for c:splineprojonucs is c:splpucs")
(princ)

 

Now you have elevation (get rid of 3dsolids and save in new DWG) witch can now be dimensioned and further used - it is all in the same scale as orig. model...

 

BTW, BTW. After you use dlls, I suggest that you use PURGE command to get rid of block used in projecting hatched canvas to 3dsolid face you picked... I think if you forget to purge it, your DWG may be corrupted when saving DWG - this is what happened when I firstly posted my example and after I had to replace it with correct one...

 

So long from me, M.R.

Posted
What I finally did is this :

- check in bios if your CPU has feature virtualization and enable it...

Download Windows6.1-KB958559-x64-RefreshPkg.msu - this is Virtual PC for Windows 7

Download WindowsXPMode_en-us.exe - this is emulator of XP Service pack 3 for Virtual PC for Windows 7

 

Install WindowsXPMode_en-us.exe

Install Windows6.1-KB958559-x64-RefreshPkg.msu

 

Then go to Start->Programs->Virtual PC->WindowsXPMode - start it => new virtual PC XP Desktop will initialize and wait to complete installation...

 

Download Autodesk AutoCAD 2009 32 bit with 32 bit keygen

Unzip archive with AutoCAD and go to Virtual PC XP mode; start windows explorer and copy unzipped folder from Windows 7 drive to XP drive (desktop if you want)...

 

Install AutoCAD 2009 32 bit on XP (use install readme and activate product with keygen)

 

Now you can use Sean's 2 dll files with netload...

 

BTW... If you plan to make elevation views from your model made from 3D solid geometry, you can use SOLPROF command to make elevations, place UCS to be parallel with made elevation geometry that will lie in one plane and use this modified routine to transform Seant's hatch splines from 3dsolids to plane :

;; Project Point onto Plane - Lee Mac
;; Projects pt onto the plane defined by its origin and normal

(defun LM:ProjectPointToPlane ( pt org nm )
(setq pt (trans pt 0 nm)
org (trans org 0 nm)
)
(trans (list (car pt) (cadr pt) (caddr org)) nm 0)
)

(defun c:splpucs nil (c:splineprojonucs))
(defun c:splineprojonucs ( / or nor ss spl splA coords coordsn fcoords fcoordsn ptx pty ptz pt ptu coordsnvar fcoordsnvar )
(vl-load-com)
(prompt "\nSelect SPLINE objects")
(while (not ss)
(setq ss (ssget "_:L" '((0 . "SPLINE"))))
)
(setq or (trans '(0.0 0.0 0.0) 1 0))
(setq nor (mapcar '- (trans '(0.0 0.0 1.0) 1 0) (trans '(0.0 0.0 0.0) 1 0)))
(repeat (setq n (sslength ss))
(setq spl (ssname ss (setq n (1- n))))
(setq splA (vlax-ename->vla-object spl))
(setq coords (vlax-safearray->list (vlax-variant-value (vla-get-ControlPoints splA))))
(if (/= (vla-get-NumberOfFitPoints splA) 0)
(setq fcoords (vlax-safearray->list (vlax-variant-value (vla-get-FitPoints splA))))
)
(setq coordsn '())
(repeat (/ (length coords) 3)
(setq ptx (car coords))
(setq pty (cadr coords))
(setq ptz (caddr coords))
(setq pt (list ptx pty ptz))
(setq ptu (LM:ProjectPointToPlane pt or nor))
(setq coords (cdddr coords))
(setq coordsn (append coordsn ptu))
)
(setq coordsnvar (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length coordsn) 1))) coordsn)))
(vla-put-ControlPoints splA coordsnvar)
(if (/= (vla-get-NumberOfFitPoints splA) 0)
(progn
(setq fcoordsn '())
(repeat (/ (length fcoords) 3)
(setq ptx (car fcoords))
(setq pty (cadr fcoords))
(setq ptz (caddr fcoords))
(setq pt (list ptx pty ptz))
(setq ptu (LM:ProjectPointToPlane pt or nor))
(setq fcoords (cdddr fcoords))
(setq fcoordsn (append fcoordsn ptu))
)
(setq fcoordsnvar (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length fcoordsn) 1))) fcoordsn)))
(vla-put-FitPoints splA fcoordsnvar)
)
)
) 
(princ)
)
(princ "\nShortcut for c:splineprojonucs is c:splpucs")
(princ)

 

Now you have elevation (get rid of 3dsolids and save in new DWG) witch can now be dimensioned and further used - it is all in the same scale as orig. model...

 

BTW, BTW. After you use dlls, I suggest that you use PURGE command to get rid of block used in projecting hatched canvas to 3dsolid face you picked... I think if you forget to purge it, your DWG may be corrupted when saving DWG - this is what happened when I firstly posted my example and after I had to replace it with correct one...

 

So long from me, M.R.

 

 

thanks for the detailed explanation M.R.

will try this out at home cause i cannot install here in the office!

again thank you!

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