"""
A little more efficient code can be written using the os module. It will be
more* error-proof *on all the platforms.
"""

erf, actually, that's not quite true, the os module can lead to errors due
to some implementations details.
The os module should be all platform relative and takes care at every level
of platform characteristics.
Unfortunately, that's not whats happening and if submitting a patch for
python wasn't so complicated, lot of patches would be submitted for sure
for this module chaining with more talks about the implementation.

let's take for example:
os.sep which is platform relative.
os,path.join is not ..

For os.path.join(), the function is based on os.isabs(), itself based on
os.splitdrive(), which leads to an unwanted behavior:
>>> os.path.join("c:/Desktop/Users/jo/", "/mydatas")
"/mydatas"
>>> os.isabs( "/mydatas")
True

os.isabs() consider as absolute all paths beginning with "/" under windows
which is silly considering thats a convention relative to Linux and UNC
paths which shouldnt be considered here ... and under windows, the
convention is "/" refers to the cwd... see a discussion here:
http://bytes.com/topic/python/answers/766249-why-os-path-isabs-windows-returns-true
This is not the only bug or undocumented behavior, you always should take
care of double checking your code and test it in more than one case !

hope it will avoid to some people headaches to understand why their tools
dont work ...

-- jo















2012/6/7 olivier jeannel <olivier.jean...@noos.fr>

>  Thank you Dan and Alok, you guys rock !
> Super cool to have online programmers (when there are no in house) ;)
>
> Olivier
>
> Le 07/06/2012 22:12, Alok a écrit :
>
> Hi Dan,
>
> A little more efficient code can be written using the os module. It will
> be more error-proof on all the platforms.
>
> import os
>
> oSources = Application.FindObjects("",
> "{BB74AA1E-12C5-11D3-B37A-00105A1E70DE}")
> for oSource in oSources:
>  filePath = oSource.Filename.value
>  fileName = os.path.basename(filePath)
>  oSource.Filename.value = os.path.join("Pictures", fileName)
>
>
>
>
> On 07/06/2012 3:41 PM, Dan Yargici wrote:
>
> Here you go.
>
>  It's very quick, dirty, crude and un-foolproof, but will basically set
> the paths of all your image sources to Pictures\Filename... :)
>
>  oSources = Application.FindObjects("",
> "{BB74AA1E-12C5-11D3-B37A-00105A1E70DE}")
> for oSource in oSources:
>  filePath = oSource.Filename.value
>  fileName = filePath.split("\\")[-1]
>  oSource.Filename.value = "Pictures\\" + fileName
>
>  DAN
>
>  On Thu, Jun 7, 2012 at 7:47 PM, olivier jeannel 
> <olivier.jean...@noos.fr>wrote:
>
>>  ...sometimes I feel like the difference between XSI and Notepad is close
>> to none :(
>>
>>
>>
>> Le 07/06/2012 18:09, Dan Yargici a écrit :
>>
>> If the search and replace supported regular expressions it'd be a breeze.
>> I would think that the way it is now makes it pretty much impossible
>> without scripting (and doing some RegExpr search/replacing...)
>>
>>  On Thu, Jun 7, 2012 at 6:03 PM, olivier jeannel <olivier.jean...@noos.fr
>> > wrote:
>>
>>>  Yes thanks !
>>>
>>> Still not able to change the textures path though. (can do it one by
>>> one), but the Search and replace doesn't seem to work on path...
>>> What is the syntax to change "every files" to   [Project
>>> path]\Pictures\every files   ?
>>>
>>>  replace
>>> Le 07/06/2012 16:39, Dan Yargici a écrit :
>>>
>>> Cool, glad it worked! :)
>>>
>>>  DAN
>>>
>>> On Thu, Jun 7, 2012 at 5:32 PM, olivier jeannel <olivier.jean...@noos.fr
>>> > wrote:
>>>
>>>>  Weird, it works well here. Maybe the file didn't finish to upload...
>>>> Could you try again ?
>>>> in case here's another
>>>> https://www.dropbox.com/s/kjiy77pt7jdv6h2/OBJ_1.zip
>>>>
>>>> FBX converter worked perfectly ! This infos worth gold !
>>>> I'm just having hard time changing the path of the pictures (textures)
>>>> in External file manager. Can't find the correct syntax.
>>>>
>>>> Olivier
>>>>
>>>>
>>>> Le 07/06/2012 16:04, Dan Yargici a écrit :
>>>>
>>>> Hi Olivier, that link doesn't work for me, I get:
>>>>
>>>>  Error Creating Link There was an error creating your link. Please try
>>>> again <https://www.dropbox.com/home>.
>>>> On Thu, Jun 7, 2012 at 4:34 PM, olivier jeannel <
>>>> olivier.jean...@noos.fr> wrote:
>>>>
>>>>>  Hi Dan,
>>>>>
>>>>> Here's the file :
>>>>>
>>>>> https://www.dropbox.com/c/shmodel?nsid=137042506&sjid=0&state=2&signature=dc46ef3&path=/OBJ_1.zip&id=shmodel
>>>>>
>>>>> Downloading the Autodesk converter atm.
>>>>>
>>>>> Le 07/06/2012 15:17, Dan Yargici a écrit :
>>>>>
>>>>> Have you tried using the Autodesk FBX Converter (converts obj also)
>>>>> found here:
>>>>>
>>>>>
>>>>> http://usa.autodesk.com/adsk/servlet/pc/item?siteID=123112&id=10775855
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Jun 7, 2012 at 4:15 PM, Dan Yargici <danyarg...@gmail.com>wrote:
>>>>>
>>>>>> Do you have an example obj you can share?
>>>>>>
>>>>>>  DAN
>>>>>>
>>>>>>
>>>>>>  On Thu, Jun 7, 2012 at 4:11 PM, olivier jeannel <
>>>>>> olivier.jean...@noos.fr> wrote:
>>>>>>
>>>>>>> Hi guys,
>>>>>>>
>>>>>>> I might have to work with CityEngine
>>>>>>> http://www.esri.com/software/cityengine/ in a near future.
>>>>>>> The Basic version of CityEngine only exports in .obj.
>>>>>>>
>>>>>>> In Softimage the opening of a sample Obj of 8 buildings (43
>>>>>>> polymesh, 43 materials, total of 1300 faces)  takes around 15s.
>>>>>>> The scene is very unstable. Hit Ctrl N, and Softimage crashes
>>>>>>> immediatly....
>>>>>>>
>>>>>>> The final city should be made of several thousands of buildings,
>>>>>>> which I think might be un-openable in Softimage.
>>>>>>>
>>>>>>> If I convert in DeepExploration in .dae Collada, dotxsi, or fbx ,
>>>>>>> when I import back in Softimages, UVs are either screwed, or disapeared.
>>>>>>> (tested in 2013, and xsi 7)
>>>>>>>
>>>>>>> When I import back those .dae, or Dotxsi in deepExploration, the Uvs
>>>>>>> are there. Everything is fine.
>>>>>>>
>>>>>>> What's happening ? What am-I supposed to do ?
>>>>>>>
>>>>>>> I need a good advice...
>>>>>>>
>>>>>>> Thank you,
>>>>>>>
>>>>>>> Olivier
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>
>

<<image/gif>>

<<image/png>>

Reply via email to